code: def metric_average(val, name):
      tensor = torch.tensor(val)  # pylint: disable=not-callable
      avg_tensor = bf.allreduce(tensor, name=name)
      return avg_tensor.item()
  
imports: from __future__ import print_function
  from bluefog.common import topology_util
  import bluefog.torch
  import argparse
  import os
  import sys
  import warnings
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import torch.utils.data.distributed
  from torchvision import datasets, transforms
label_desc: Use image node_id 3 for calling a global function with example usage: metric_average(val, name) and returns: avg_tensor