code: def scatter(inputs, target_gpus, chunk_sizes, dim=0):
      r"""
      Slices tensors into approximately equal chunks and
      distributes them across given GPUs. Duplicates
      references to objects that are not tensors.
      """
  
      def scatter_map(obj):
          if isinstance(obj, torch.Tensor):
              try:
                  return Scatter.apply(
                      target_gpus, chunk_sizes, dim, obj
                  )
              except:
                  print("obj", obj.size())
                  print("dim", dim)
                  print("chunk_sizes", chunk_sizes)
                  quit()
          if isinstance(obj, tuple) and len(obj) > 0:
              return list(zip(*map(scatter_map, obj)))
          if isinstance(obj, list) and len(obj) > 0:
              return list(map(list, zip(*map(scatter_map, obj))))
          if isinstance(obj, dict) and len(obj) > 0:
              return list(
                  map(type(obj), zip(*map(scatter_map, obj.items())))
              )
          return [obj for targets in target_gpus]
  
      # After scatter_map is called, a scatter_map cell will exist. This cell
      # has a reference to the actual function scatter_map, which has references
      # to a closure that has a reference to the scatter_map cell (because the
      # fn is recursive). To avoid this reference cycle, we set the function to
      # None, clearing the cell
      try:
          return scatter_map(inputs)
      finally:
          scatter_map = None
  
file_path: smart-moe/examples/transformer-xl/utils/data_parallel.py
imports: from torch.nn.parallel import DataParallel
  import torch
  from torch.nn.parallel._functions import Scatter
  from torch.nn.parallel.parallel_apply import parallel_apply
label_desc: Use image node_id 1 for calling a global function with example usage: scatter(inputs, target_gpus, chunk_sizes, dim) and returns: unknown, scatter_map, list, list, list, Scatter