code: def reduce_value(value, average=True):
      world_size = get_world_size()
      if world_size < 2:  # 单GPU的情况
          return value
  
      with torch.no_grad():
          dist.all_reduce(value)
          if average:
              value /= world_size
  
          return value
  
file_path: deep-learning-for-image-processing/pytorch_classification/mini_imagenet/multi_train_utils/distributed_utils.py
imports: import os
  import torch
  import torch.distributed
label_desc: Use image node_id 7 for calling a global function with example usage: reduce_value(value, average) and returns: value, value