code: def scatter(input, devices, streams=None):
      """Scatters tensor across multiple GPUs."""
      if streams is None:
          streams = [None] * len(devices)
  
      if isinstance(input, list):
          chunk_size = (len(input) - 1) // len(devices) + 1
          outputs = [
              scatter(
                  input[i],
                  [devices[i // chunk_size]],
                  [streams[i // chunk_size]],
              )
              for i in range(len(input))
          ]
          return outputs
      elif isinstance(input, torch.Tensor):
          output = input.contiguous()
          # TODO: copy to a pinned buffer first (if copying from CPU)
          stream = streams[0] if output.numel() > 0 else None
          if devices != [-1]:
              with torch.cuda.device(devices[0]), torch.cuda.stream(
                  stream
              ):
                  output = output.cuda(devices[0], non_blocking=True)
          else:
              # unsqueeze the first dimension thus the tensor's shape is the
              # same as those scattered with GPU.
              output = output.unsqueeze(0)
          return output
      else:
          raise Exception(f"Unknown type {type(input)}.")
  
imports: import torch
  from torch.nn.parallel._functions import _get_stream
label_desc: Use image node_id 1 for calling a global function with example usage: scatter(input, devices, streams) and returns: outputs, output