code: def gather_tensors_from_all(
      tensor: torch.Tensor,
  ) -> List[torch.Tensor]:
      """
      Wrapper over torch.distributed.all_gather for performing
      'gather' of 'tensor' over all processes in both distributed /
      non-distributed scenarios.
      """
      if tensor.ndim == 0:
          # 0 dim tensors cannot be gathered. so unsqueeze
          tensor = tensor.unsqueeze(0)
  
      if is_distributed_training_run():
          tensor, orig_device = convert_to_distributed_tensor(tensor)
          gathered_tensors = [
              torch.zeros_like(tensor)
              for _ in range(torch.distributed.get_world_size())
          ]
          torch.distributed.all_gather(gathered_tensors, tensor)
          gathered_tensors = [
              convert_to_normal_tensor(_tensor, orig_device)
              for _tensor in gathered_tensors
          ]
      else:
          gathered_tensors = [tensor]
  
      return gathered_tensors
  
imports: import io
  import tempfile
  from typing import Any, Callable, List, Tuple
  import torch
label_desc: Use image node_id 10 for calling a global function with example usage: gather_tensors_from_all(tensor) and returns: gathered_tensors