from tensorflow.python.framework import ops

  with ops.name_scope(
      name, 'expand_and_tile', (tensor, multiple, dim)) as scope:
    # Sparse.
    if isinstance(tensor, ops.SparseTensorValue):
      tensor = ops.SparseTensor.from_value(tensor)
    if isinstance(tensor, ops.SparseTensor):
      if dim < 0:
        expand_dims = array_ops.reshape(
