code: def reduce_tensor(tensor):
      rt = tensor.clone().detach()
      dist.all_reduce(rt, op=dist.ReduceOp.SUM)
      rt /= (
          torch.distributed.get_world_size()
          if torch.distributed.is_initialized()
          else 1
      )
      return rt
  
imports: import math
  import os
  import numpy
  import torch
  import shutil
  import signal
  import torch.distributed
label_desc: Use image node_id 4 for calling a global function with example usage: reduce_tensor(tensor) and returns: rt