code: def margins(a):
      """Return a list of the marginal sums of the array `a`.
  
      Parameters
      ----------
      a : ndarray
          The array for which to compute the marginal sums.
  
      Returns
      -------
      margsums : list of ndarrays
          A list of length `a.ndim`.  `margsums[k]` is the result
          of summing `a` over all axes except `k`; it has the same
          number of dimensions as `a`, but the length of each axis
          except axis `k` will be 1.
  
      Examples
      --------
      >>> a = np.arange(12).reshape(2, 6)
      >>> a
      array([[ 0,  1,  2,  3,  4,  5],
             [ 6,  7,  8,  9, 10, 11]])
      >>> from scipy.stats.contingency import margins
      >>> m0, m1 = margins(a)
      >>> m0
      array([[15],
             [51]])
      >>> m1
      array([[ 6,  8, 10, 12, 14, 16]])
  
      >>> b = np.arange(24).reshape(2,3,4)
      >>> m0, m1, m2 = margins(b)
      >>> m0
      array([[[ 66]],
             [[210]]])
      >>> m1
      array([[[ 60],
              [ 92],
              [124]]])
      >>> m2
      array([[[60, 66, 72, 78]]])
      """
      margsums = []
      ranged = list(range(a.ndim))
      for k in ranged:
          marg = np.apply_over_axes(
              np.sum, a, [j for j in ranged if j != k]
          )
          margsums.append(marg)
      return margsums
  
file_path: catboost/contrib/python/scipy/py3/scipy/stats/contingency.py
imports: from functools import reduce
  import math
  import numpy
  from .stats import power_divergence
  from ._relative_risk import relative_risk
  from ._crosstab import crosstab
label_desc: Use image node_id 1 for calling a global function with example usage: margins(a) and returns: margsums