code: def sum(
      x: Union[ivy.Array, ivy.NativeArray],
      /,
      *,
      axis: Optional[Union[int, Sequence[int]]] = None,
      dtype: Optional[Union[ivy.Dtype, ivy.NativeDtype]] = None,
      keepdims: Optional[bool] = False,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Calculate the sum of the input array x.
  
      **Special Cases**
  
      Let ``N`` equal the number of elements over which to compute the sum.
      -   If ``N`` is ``0``, the sum is ``0`` (i.e., the empty sum).
  
      For floating-point operands,
      -   If ``x_i`` is ``NaN``, the sum is ``NaN`` (i.e., ``NaN`` values propagate).
  
      For both real-valued and complex floating-point operands, special cases must
      be handled as if the operation is implemented by successive application of
      :func:`ivy.add`:
  
      Parameters
      ----------
      x
          Input array. Should have a numeric data type.
      axis
          Axis or axes along which sums must be computed. By default, the sum must be
          computed over the entire array. If a tuple of integers, sums must be computed
          over multiple axes. Default: ``None``.
      dtype
          Data type of the returned array. If ``None``,
              If the default data type corresponding to the data type "kind" (integer or
              floating-point) of ``x`` has a smaller range of values than the data type of
              ``x`` (e.g., ``x`` has data type ``int64`` and the default data type is
              ``int32``, or ``x`` has data type ``uint64`` and the default data type is
              ``int64``), the returned array must have the same data type as ``x``.
              If ``x`` has a floating-point data type, the returned array must have the
              default floating-point data type.
              If ``x`` has a signed integer data type (e.g., ``int16``), the returned
              array must have the default integer data type.
              If ``x`` has an unsigned integer data type (e.g., ``uint16``), the returned
              array must have an unsigned integer data type having the same number of bits
              as the default integer data type (e.g., if the default integer data type is
              ``int32``, the returned array must have a ``uint32`` data type).
  
          If the data type (either specified or resolved) differs from the data type of
          ``x``, the input array should be cast to the specified data type before
          computing the sum. Default: ``None``.
  
          .. note::
              keyword argument is intended to help prevent data type overflows.
  
      keepdims
          If ``True``, the reduced axes (dimensions) must be included in the result as
          singleton dimensions, and, accordingly, the result must be compatible with the
          input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes
          (dimensions) must not be included in the result. Default: ``False``.
      out
          optional output array, for writing the result to.
  
      Returns
      -------
      ret
          If the sum was computed over the entire array, a zero-dimensional array
          containing the sum; otherwise, an array containing the sums. The returned array
          must have a data type as described by the ``dtype`` parameter above.
  
  
      This function conforms to the `Array API Standard
      <https://data-apis.org/array-api/latest/>`_. This docstring is an extension of the
      `docstring <https://data-apis.org/array-api/latest/
      API_specification/generated/array_api.sum.html>`_
      in the standard.
  
      Both the description and the type hints above assumes an array input for simplicity,
      but this function is *nestable*, and therefore also accepts :class:`ivy.Container`
      instances in place of any of the arguments.
  
      Examples
      --------
      With :class:`ivy.Array` input:
  
      >>> x = ivy.array([0.41, 0.89])
      >>> y = ivy.sum(x)
      >>> print(y)
      ivy.array(1.3)
  
      >>> x = ivy.array([0.5, 0.7, 2.4])
      >>> y = ivy.array(0.0)
      >>> ivy.sum(x, out=y)
      >>> print(y)
      ivy.array(3.6)
  
      >>> x = ivy.array([[0, 1, 2], [4, 6, 10]])
      >>> y = ivy.sum(x, axis = 1, keepdims = False)
      >>> print(y)
      ivy.array([3, 20])
  
      >>> x = ivy.array([[0, 1, 2], [4, 6, 10]])
      >>> y = ivy.array([0,0,0])
      >>> ivy.sum(x, axis = 0, keepdims = False, out = y)
      >>> print(y)
      ivy.array([4, 7, 12])
  
      With :class:`ivy.NativeArray` input:
  
      >>> x = ivy.native_array([0.1, 0.2, 0.3, 0.3, 0.9, 0.10])
      >>> y = ivy.sum(x)
      >>> print(y)
      ivy.array(1.9)
  
      >>> x = ivy.native_array([1.0, 2.0, 2.0, 3.0])
      >>> y = ivy.array(0.0)
      >>> ivy.sum(x, out=y)
      >>> print(y)
      ivy.array(8.)
  
      With :class:`ivy.Container` input:
  
      >>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.]))
      >>> y = ivy.sum(x)
      >>> print(y)
      {
          a: ivy.array(3.),
          b: ivy.array(12.)
      }
      """
      return current_backend(x).sum(
          x, axis=axis, dtype=dtype, keepdims=keepdims, out=out
      )
  
file_path: ivy/ivy/functional/ivy/statistical.py
imports: from typing import Union, Optional, Sequence
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, to_native_arrays_and_back, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 7 for calling a global function with example usage: sum() and returns: current_backend