code: def _stable_cumsum(arr, axis=None, rtol=1e-05, atol=1e-08):
      """Use high precision for cumsum and check that final value matches sum
  
      Parameters
      ----------
      arr : array-like
          To be cumulatively summed as flat
      axis : int, optional
          Axis along which the cumulative sum is computed.
          The default (None) is to compute the cumsum over the flattened array.
      rtol : float
          Relative tolerance, see ``np.allclose``
      atol : float
          Absolute tolerance, see ``np.allclose``
      """
      out = np.cumsum(arr, axis=axis, dtype=np.float64)
      expected = np.sum(arr, axis=axis, dtype=np.float64)
      if not np.all(
          np.isclose(
              out.take(-1, axis=axis),
              expected,
              rtol=rtol,
              atol=atol,
              equal_nan=True,
          )
      ):
          raise ValueError(Errors.E163)
      return out
  
imports: from collections import defaultdict
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple
  import numpy
  from .errors import Errors
  from .morphology import Morphology
  from .tokens import Doc, Span, Token
  from .training import Example
  from .util import SimpleFrozenList, get_lang_class
label_desc: Use image node_id 6 for calling a global function with example usage: _stable_cumsum(arr, axis, rtol, atol) and returns: out