Converts `value` into a tensor that can be feed into `tensor_info`.

  Args:
    value: A value to convert into Tensor or SparseTensor.
    target: An object returned by `parse_tensor_info_map`.
    error_prefix: A string to prefix on raised TypeErrors.

  Raises:
    TypeError: If it fails to convert.

  Returns:
    A Tensor or SparseTensor compatible with tensor_info.

def _convert_to_compatible_tensor(value, target, error_prefix):
  """Converts `value` into a tensor that can be feed into `tensor_info`.

  Args:
    value: A value to convert into Tensor or SparseTensor.
    target: An object returned by `parse_tensor_info_map`.
    error_prefix: A string to prefix on raised TypeErrors.

  Raises:
    TypeError: If it fails to convert.

  Returns:
    A Tensor or SparseTensor compatible with tensor_info.
  """
  try:
    tensor = tf_v1.convert_to_tensor_or_indexed_slices(value, target.dtype)
  except TypeError as e:
    raise TypeError("%s: %s" % (error_prefix, e))
  if _is_sparse(tensor) != _is_sparse(target):
    if _is_sparse(tensor):
      raise TypeError("%s: Is sparse. Expected dense." % error_prefix)
    else:
      raise TypeError("%s: Is dense. Expected sparse." % error_prefix)
  if not tensor.get_shape().is_compatible_with(target.get_shape()):
    raise TypeError("%s: Shape %r is incompatible with %r" %
                    (error_prefix, tensor.get_shape(), target.get_shape()))
  return tensor