code: def normalise(v, dimN=2):
      r
  
      axisN = tuple(range(0, dimN))
      vn = np.sqrt(np.sum(v**2, axisN, keepdims=True))
      vn[vn == 0] = 1.0
      return np.asarray(v / vn, dtype=v.dtype)
docs: r"""Normalise vectors, corresponding to slices along specified number
      of initial spatial dimensions of an array, to have unit
      :math:`\ell_2` norm. The remaining axes enumerate the distinct
      vectors to be normalised.
  
      Parameters
      ----------
      v : array_like
        Array with components to be normalised
      dimN : int, optional (default 2)
        Number of initial dimensions over which norm should be computed
  
      Returns
      -------
      vnrm : ndarray
        Normalised array