def unwrap(tensor):
  """Returns the underlying tensor if tensor is wrapped or tensor.

  Args:
    tensor: The tensor to unwrap.
  Returns:
    Tensor or if it is a pretty tensor, the unwrapped version.
  Raises:
    ValueError: if tensor holds a sequence.
  """
  while isinstance(tensor, (PrettyTensor, Loss)):
    tensor = tensor.tensor
  return tensor
Returns the underlying tensor if tensor is wrapped or tensor.

  Args:
    tensor: The tensor to unwrap.
  Returns:
    Tensor or if it is a pretty tensor, the unwrapped version.
  Raises:
    ValueError: if tensor holds a sequence.