code: def _reduce(input_, pg: ProcessGroup):
      # skip if only one rank involved
      if pg.tp_world_size() == 1:
          return input_
      assert input_.device.type == "cuda"
      group = pg.tp_process_group()
      dist.all_reduce(input_, group=group)
  
      return input_
  
imports: from typing import List, Optional, Union
  import torch
  import torch.distributed
  from colossalai.legacy.global_variables import tensor_parallel_env
  from colossalai.legacy.nn.layer.utils import divide
  from colossalai.legacy.tensor import ColoTensorSpec, ProcessGroup
  from colossalai.tensor import ColoTensor
label_desc: Use image node_id 6 for calling a global function with example usage: _reduce(input_, pg) and returns: input_, input_