code: def get_tensor_n_elements(tensor):
      """Return the number of elements in a tensor."""
      if isinstance(tensor, cupy.ndarray) or isinstance(
          tensor, numpy.ndarray
      ):
          return tensor.size
      if torch_available():
          if isinstance(tensor, torch.Tensor):
              return torch.numel(tensor)
      raise ValueError(
          "Unsupported tensor type. Got: {}. Supported "
          "GPU tensor types are: torch.Tensor, "
          "cupy.ndarray.".format(type(tensor))
      )
  
file_path: ray/python/ray/util/collective/collective_group/nccl_util.py
imports: import numpy
  from ray.util.collective.types import ReduceOp, torch_available
label_desc: Use image node_id 10 for calling a global function with example usage: get_tensor_n_elements(tensor) and returns: tensor, torch