def _ReductionDims(x, axis, reduction_indices=None):
    'Returns range(0, rank(x)) if reduction_indices is None.'
    if (reduction_indices is not None):
        if (axis is not None):
            raise ValueError("Can't specify both axis' and 'reduction_indices'.")
        axis = reduction_indices
    if (axis is not None):
        return axis
    else:
        rank = common_shapes.rank(x)
        if (rank is not None):
            return constant_op.constant(np.arange(rank), dtype=dtypes.int32)
        if (isinstance(x, sparse_tensor.SparseTensor) and x.dense_shape.shape.is_fully_defined()):
            rank = x.dense_shape.shape.dims[0].value
            return constant_op.constant(np.arange(rank), dtype=dtypes.int32)
        return range(0, array_ops.rank(x))
Returns range(0, rank(x)) if reduction_indices is None.
def _ReductionDims(x, axis, reduction_indices=None):
    
    if (reduction_indices is not None):
        if (axis is not None):
            raise ValueError("Can't specify both axis' and 'reduction_indices'.")
        axis = reduction_indices
    if (axis is not None):
        return axis
    else:
        rank = common_shapes.rank(x)
        if (rank is not None):
            return constant_op.constant(np.arange(rank), dtype=dtypes.int32)
        if (isinstance(x, sparse_tensor.SparseTensor) and x.dense_shape.shape.is_fully_defined()):
            rank = x.dense_shape.shape.dims[0].value
            return constant_op.constant(np.arange(rank), dtype=dtypes.int32)
        return range(0, array_ops.rank(x))