code: def scaled_all_reduce(tensors):
      """
      Performs the scaled all_reduce operation on the provided tensors.
  
      The input tensors are modified in-place. Currently supports only the sum
      reduction operator. The reduced values are scaled by the inverse size of the
      process group (equivalent to cfg.NUM_GPUS).
      """
      # There is no need for reduction in the single-proc case
      if cfg.NUM_GPUS == 1:
          return tensors
      # Queue the reductions
      reductions = []
      for tensor in tensors:
          reduction = torch.distributed.all_reduce(
              tensor, async_op=True
          )
          reductions.append(reduction)
      # Wait for reductions to finish
      for reduction in reductions:
          reduction.wait()
      # Scale the results
      for tensor in tensors:
          tensor.mul_(1.0 / cfg.NUM_GPUS)
      return tensors
  
file_path: pycls/pycls/core/distributed.py
imports: import os
  import random
  import submitit
  import torch
  from pycls.core.config import cfg
label_desc: Use image node_id 2 for calling a global function with example usage: scaled_all_reduce(tensors) and returns: tensors, tensors