@tf_export('math.accumulate_n', v1=['math.accumulate_n', 'accumulate_n'])
@deprecation.deprecated_endpoints('accumulate_n')
def accumulate_n(inputs, shape=None, tensor_dtype=None, name=None):
    "Returns the element-wise sum of a list of tensors.\n\n  Optionally, pass `shape` and `tensor_dtype` for shape and type checking,\n  otherwise, these are inferred.\n\n  `tf.math.accumulate_n` performs the same operation as `tf.add_n`, but does not\n  wait for all of its inputs to be ready before beginning to sum. This can\n  save memory if inputs are ready at different times, since minimum temporary\n  storage is proportional to the output size rather than the inputs size.\n\n  `accumulate_n` is differentiable (but wasn't previous to TensorFlow 1.7).\n\n  For example:\n\n  ```python\n  a = tf.constant([[1, 2], [3, 4]])\n  b = tf.constant([[5, 0], [0, 6]])\n  tf.math.accumulate_n([a, b, a])  # [[7, 4], [6, 14]]\n\n  # Explicitly pass shape and type\n  tf.math.accumulate_n([a, b, a], shape=[2, 2], tensor_dtype=tf.int32)\n                                                                 # [[7,  4],\n                                                                 #  [6, 14]]\n  ```\n\n  Args:\n    inputs: A list of `Tensor` objects, each with same shape and type.\n    shape: Shape of elements of `inputs`.\n    tensor_dtype: The type of `inputs`.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `Tensor` of same shape and type as the elements of `inputs`.\n\n  Raises:\n    ValueError: If `inputs` don't all have same shape and dtype or the shape\n    cannot be inferred.\n  "

    def _input_error():
        return ValueError('inputs must be a list of at least one Tensor with the same dtype and shape')
    if ((not inputs) or (not isinstance(inputs, (list, tuple)))):
        raise _input_error()
    inputs = ops.convert_n_to_tensor_or_indexed_slices(inputs)
    if (not all((isinstance(x, ops.Tensor) for x in inputs))):
        raise _input_error()
    if (not all(((x.dtype == inputs[0].dtype) for x in inputs))):
        raise _input_error()
    if (shape is not None):
        shape = tensor_shape.as_shape(shape)
    else:
        shape = tensor_shape.unknown_shape()
    for input_tensor in inputs:
        if isinstance(input_tensor, ops.Tensor):
            shape = shape.merge_with(input_tensor.get_shape())
    if ((tensor_dtype is not None) and (tensor_dtype != inputs[0].dtype)):
        raise TypeError('tensor_dtype is {}, but input is of type {}'.format(tensor_dtype, inputs[0].dtype))
    if ((len(inputs) == 1) and (name is None)):
        return inputs[0]
    elif ((len(inputs) == 1) and (name is not None)):
        return array_ops.identity(inputs[0], name=name)
    elif context.executing_eagerly():
        return add_n(inputs, name=name)
    else:
        return gen_math_ops.accumulate_nv2(inputs, name=name, shape=shape)
Returns the element-wise sum of a list of tensors.

Optionally, pass `shape` and `tensor_dtype` for shape and type checking,
otherwise, these are inferred.

`tf.math.accumulate_n` performs the same operation as `tf.add_n`, but does not
wait for all of its inputs to be ready before beginning to sum. This can
save memory if inputs are ready at different times, since minimum temporary
storage is proportional to the output size rather than the inputs size.

`accumulate_n` is differentiable (but wasn't previous to TensorFlow 1.7).

For example:

```python
a = tf.constant([[1, 2], [3, 4]])
b = tf.constant([[5, 0], [0, 6]])
tf.math.accumulate_n([a, b, a])  # [[7, 4], [6, 14]]

# Explicitly pass shape and type
tf.math.accumulate_n([a, b, a], shape=[2, 2], tensor_dtype=tf.int32)
                                                               # [[7,  4],
                                                               #  [6, 14]]
```

Args:
  inputs: A list of `Tensor` objects, each with same shape and type.
  shape: Shape of elements of `inputs`.
  tensor_dtype: The type of `inputs`.
  name: A name for the operation (optional).

Returns:
  A `Tensor` of same shape and type as the elements of `inputs`.

Raises:
  ValueError: If `inputs` don't all have same shape and dtype or the shape
  cannot be inferred.
@tf_export('math.accumulate_n', v1=['math.accumulate_n', 'accumulate_n'])
@deprecation.deprecated_endpoints('accumulate_n')
def accumulate_n(inputs, shape=None, tensor_dtype=None, name=None):
    "Returns the element-wise sum of a list of tensors.\n\n  Optionally, pass `shape` and `tensor_dtype` for shape and type checking,\n  otherwise, these are inferred.\n\n  `tf.math.accumulate_n` performs the same operation as `tf.add_n`, but does not\n  wait for all of its inputs to be ready before beginning to sum. This can\n  save memory if inputs are ready at different times, since minimum temporary\n  storage is proportional to the output size rather than the inputs size.\n\n  `accumulate_n` is differentiable (but wasn't previous to TensorFlow 1.7).\n\n  For example:\n\n  ```python\n  a = tf.constant([[1, 2], [3, 4]])\n  b = tf.constant([[5, 0], [0, 6]])\n  tf.math.accumulate_n([a, b, a])  # [[7, 4], [6, 14]]\n\n  # Explicitly pass shape and type\n  tf.math.accumulate_n([a, b, a], shape=[2, 2], tensor_dtype=tf.int32)\n                                                                 # [[7,  4],\n                                                                 #  [6, 14]]\n  ```\n\n  Args:\n    inputs: A list of `Tensor` objects, each with same shape and type.\n    shape: Shape of elements of `inputs`.\n    tensor_dtype: The type of `inputs`.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `Tensor` of same shape and type as the elements of `inputs`.\n\n  Raises:\n    ValueError: If `inputs` don't all have same shape and dtype or the shape\n    cannot be inferred.\n  "

    def _input_error():
        return ValueError('inputs must be a list of at least one Tensor with the same dtype and shape')
    if ((not inputs) or (not isinstance(inputs, (list, tuple)))):
        raise _input_error()
    inputs = ops.convert_n_to_tensor_or_indexed_slices(inputs)
    if (not all((isinstance(x, ops.Tensor) for x in inputs))):
        raise _input_error()
    if (not all(((x.dtype == inputs[0].dtype) for x in inputs))):
        raise _input_error()
    if (shape is not None):
        shape = tensor_shape.as_shape(shape)
    else:
        shape = tensor_shape.unknown_shape()
    for input_tensor in inputs:
        if isinstance(input_tensor, ops.Tensor):
            shape = shape.merge_with(input_tensor.get_shape())
    if ((tensor_dtype is not None) and (tensor_dtype != inputs[0].dtype)):
        raise TypeError('tensor_dtype is {}, but input is of type {}'.format(tensor_dtype, inputs[0].dtype))
    if ((len(inputs) == 1) and (name is None)):
        return inputs[0]
    elif ((len(inputs) == 1) and (name is not None)):
        return array_ops.identity(inputs[0], name=name)
    elif context.executing_eagerly():
        return add_n(inputs, name=name)
    else:
        return gen_math_ops.accumulate_nv2(inputs, name=name, shape=shape)