code: def all_gather(
      tensor: Union[torch.Tensor, float, str, Any],
      group: Optional[Union[Any, List[int]]] = None,
  ) -> Union[torch.Tensor, float, List[float], List[str], List[Any]]:
      """Helper method to perform all gather operation.
  
      Args:
          tensor: tensor or number or str to collect across participating processes. If tensor, it should have the
              same shape across processes.
          group: list of integer or the process group for each backend. If None, the default process group will be used.
  
      Returns:
          If input is a tensor, returns a torch.Tensor of shape ``(world_size * tensor.shape[0], tensor.shape[1], ...)``.
          If input is a number, a torch.Tensor of shape ``(world_size, )`` is returned and finally a list of strings
          is returned if input is a string. If current process does not belong to `group`, the very ``tensor`` is
          returned.
  
      .. versionchanged:: 0.4.11
          added ``group``
      """
      if _need_to_sync and isinstance(_model, _SerialModel):
          sync(temporary=True)
  
      if isinstance(group, list) and all(
          isinstance(item, int) for item in group
      ):
          group = _model.new_group(group)
  
      return _model.all_gather(tensor, group=group)
  
imports: import socket
  from contextlib import contextmanager
  from functools import wraps
  from typing import Any, Callable, List, Mapping, Optional, Tuple, Union
  import torch
  from ignite.distributed.comp_models import _SerialModel, has_hvd_support, has_native_dist_support, has_xla_support, registered_computation_models
  from ignite.utils import setup_logger
label_desc: Use image node_id 15 for calling a global function with example usage: all_gather(tensor, group) and returns: _model