class_docstr: Strategy for training multiple TPU devices using the :func:`torch_xla.distributed.xla_multiprocessing.spawn`
  method.
docstr: Function to gather a tensor from several distributed processes.
  
  Args:
      tensor: tensor to all-gather.
      group: unused.
      sync_grads: flag that allows users to synchronize gradients for the all-gather operation.
  Return:
      A tensor of shape (world_size, ...)
docstr_tok: ["Function","to","gather","a","tensor","from","several","distributed","processes",".","Args",":","tensor",":","tensor","to","all-gather",".","group",":","unused",".","sync_grads",":","flag","that","allows","users","to","synchronize","gradients","for","the","all-gather","operation",".","Return",":","A","tensor","of","shape","(","world_size",",","...",")"]
code: def all_gather(
      self,
      tensor: Tensor,
      group: Optional[Any] = None,
      sync_grads: bool = False,
  ) -> Tensor:
      """Function to gather a tensor from several distributed processes.
  
      Args:
          tensor: tensor to all-gather.
          group: unused.
          sync_grads: flag that allows users to synchronize gradients for the all-gather operation.
      Return:
          A tensor of shape (world_size, ...)
  
      """
      if not self._launched:
          return tensor
      if not isinstance(tensor, Tensor):
          raise NotImplementedError(
              f"`{type(self).__name__}.all_gather` is only implemented for tensors. Given {tensor}"
          )
      if tensor.dim() == 0:
          tensor = tensor.unsqueeze(0)
      original_device = tensor.device
      tensor = tensor.to(self.root_device)
  
      import torch_xla.core.functions as xf
      import torch_xla.core.xla_model as xm
  
      tensor = (
          xf.all_gather(tensor) if sync_grads else xm.all_gather(tensor)
      )
      tensor = tensor.to(original_device)
      return tensor
  
imports: import io
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch.nn import Module
  from torch.optim import Optimizer
  from torch.utils.data import DataLoader
  from typing_extensions import override
  from lightning.fabric.accelerators import Accelerator
  from lightning.fabric.accelerators.xla import _XLA_GREATER_EQUAL_2_1
  from lightning.fabric.plugins import XLAPrecision
  from lightning.fabric.plugins.environments import XLAEnvironment
  from lightning.fabric.plugins.io.xla import XLACheckpointIO
  from lightning.fabric.strategies import ParallelStrategy, _StrategyRegistry
  from lightning.fabric.strategies.launchers.xla import _XLALauncher
  from lightning.fabric.strategies.strategy import TBroadcast
  from lightning.fabric.utilities.rank_zero import rank_zero_only
  from lightning.fabric.utilities.types import _PATH, ReduceOp
label_desc: Use image node_id 17 for calling the XLAStrategy obj's underlying member method code with example usage: obj.all_gather(tensor, group, sync_grads) and returns: tensor, tensor