code: def all_gather(x):
      world_size = torch.distributed.get_world_size()
      if world_size > 1:
          rank = torch.distributed.get_rank()
          x_list = [torch.ones_like(x) for _ in range(world_size)]
          torch.distributed.all_gather(x_list, x.contiguous())
          # remove curr rank
          x_list.pop(rank)
          return torch.cat(x_list, dim=0)
      return None
  
imports: import torch
  from ..losses import BaseMetricLossFunction, CrossBatchMemory
  from ..miners import BaseMiner
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
label_desc: Use image node_id 2 for calling a global function with example usage: all_gather(x) and returns: None, torch