@tf_export(v1=['math.scalar_mul', 'scalar_mul'])
def scalar_mul(scalar, x, name=None):
    'Multiplies a scalar times a `Tensor` or `IndexedSlices` object.\n\n  Intended for use in gradient code which might deal with `IndexedSlices`\n  objects, which are easy to multiply by a scalar but more expensive to\n  multiply with arbitrary tensors.\n\n  Args:\n    scalar: A 0-D scalar `Tensor`. Must have known shape.\n    x: A `Tensor` or `IndexedSlices` to be scaled.\n    name: A name for the operation (optional).\n\n  Returns:\n    `scalar * x` of the same type (`Tensor` or `IndexedSlices`) as `x`.\n\n  Raises:\n    ValueError: if scalar is not a 0-D `scalar`.\n  '
    scalar = ops.convert_to_tensor(scalar, dtype=x.dtype.base_dtype, name='scalar')
    shape = scalar.get_shape()
    if (shape.ndims == 0):
        if isinstance(x, ops.IndexedSlices):
            return ops.IndexedSlices(gen_math_ops.mul(scalar, x.values, name), x.indices, x.dense_shape)
        else:
            return gen_math_ops.mul(scalar, x, name)
    else:
        raise ValueError(('Only scalar multiply works, got shape %s' % shape))
Multiplies a scalar times a `Tensor` or `IndexedSlices` object.

Intended for use in gradient code which might deal with `IndexedSlices`
objects, which are easy to multiply by a scalar but more expensive to
multiply with arbitrary tensors.

Args:
  scalar: A 0-D scalar `Tensor`. Must have known shape.
  x: A `Tensor` or `IndexedSlices` to be scaled.
  name: A name for the operation (optional).

Returns:
  `scalar * x` of the same type (`Tensor` or `IndexedSlices`) as `x`.

Raises:
  ValueError: if scalar is not a 0-D `scalar`.
@tf_export(v1=['math.scalar_mul', 'scalar_mul'])
def scalar_mul(scalar, x, name=None):
    'Multiplies a scalar times a `Tensor` or `IndexedSlices` object.\n\n  Intended for use in gradient code which might deal with `IndexedSlices`\n  objects, which are easy to multiply by a scalar but more expensive to\n  multiply with arbitrary tensors.\n\n  Args:\n    scalar: A 0-D scalar `Tensor`. Must have known shape.\n    x: A `Tensor` or `IndexedSlices` to be scaled.\n    name: A name for the operation (optional).\n\n  Returns:\n    `scalar * x` of the same type (`Tensor` or `IndexedSlices`) as `x`.\n\n  Raises:\n    ValueError: if scalar is not a 0-D `scalar`.\n  '
    scalar = ops.convert_to_tensor(scalar, dtype=x.dtype.base_dtype, name='scalar')
    shape = scalar.get_shape()
    if (shape.ndims == 0):
        if isinstance(x, ops.IndexedSlices):
            return ops.IndexedSlices(gen_math_ops.mul(scalar, x.values, name), x.indices, x.dense_shape)
        else:
            return gen_math_ops.mul(scalar, x, name)
    else:
        raise ValueError(('Only scalar multiply works, got shape %s' % shape))