code: def _z_scale(ary):
      """Calculate z_scale.
  
      Parameters
      ----------
      ary : np.ndarray
  
      Returns
      -------
      np.ndarray
      """
      ary = np.asarray(ary)
      if packaging.version.parse(
          scipy.__version__
      ) < packaging.version.parse("1.10.0.dev0"):
          rank = stats.rankdata(ary, method="average")
      else:
          # the .ravel part is only needed to overcom a bug in scipy 1.10.0.rc1
          rank = (
              stats.rankdata(  # pylint: disable=unexpected-keyword-arg
                  ary, method="average", nan_policy="omit"
              )
          )
      rank = _backtransform_ranks(rank)
      z = stats.norm.ppf(rank)
      z = z.reshape(ary.shape)
      return z
  
imports: import warnings
  from collections.abc import Sequence
  import numpy
  import packaging
  import pandas
  import scipy
  from scipy import stats
  from ..data import convert_to_dataset
  from ..utils import Numba, _numba_var, _stack, _var_names
  from .density_utils import histogram
  from .stats_utils import _circular_standard_deviation, _sqrt
  from .stats_utils import autocov
  from .stats_utils import not_valid
  from .stats_utils import quantile
  from .stats_utils import stats_variance_2d
  from .stats_utils import wrap_xarray_ufunc
label_desc: Use image node_id 8 for calling a global function with example usage: _z_scale(ary) and returns: z