code: def clamp_tensor(tensor, minimum, maximum):
      
      if tensor.is_sparse:
          coalesced_tensor = tensor.coalesce()
          # pylint: disable=protected-access
          coalesced_tensor._values().clamp_(minimum, maximum)
          return coalesced_tensor
      else:
          return tensor.clamp(minimum, maximum)
docs: Supports sparse and dense tensors.
      Returns a tensor with values clamped between the provided minimum and maximum,
      without modifying the original tensor.