code: def flat_dist_call(tensors, call, extra_args=None):
      flat_dist_call.warn_on_half = True
      buckets = {}
      for tensor in tensors:
          tp = tensor.type()
          if tp not in buckets:
              buckets[tp] = []
          buckets[tp].append(tensor)
  
      if flat_dist_call.warn_on_half:
          if torch.cuda.HalfTensor in buckets:
              print(
                  "WARNING: gloo dist backend for half parameters may be extremely slow."
                  + " It is recommended to use the NCCL backend in this case."
              )
              flat_dist_call.warn_on_half = False
  
      for tp in buckets:
          bucket = buckets[tp]
          coalesced = _flatten_dense_tensors(bucket)
          if extra_args is not None:
              call(coalesced, *extra_args)
          else:
              call(coalesced)
          coalesced /= dist.get_world_size()
          for buf, synced in zip(
              bucket, _unflatten_dense_tensors(coalesced, bucket)
          ):
              buf.copy_(synced)
  
file_path: DALI/docs/examples/use_cases/video_superres/common/distributed.py
imports: import torch
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
  import torch.distributed
  from torch.nn.modules import Module
label_desc: Use image node_id 1 for calling a global function with example usage: flat_dist_call(tensors, call, extra_args) without return types