class_docstr: Copies tensors on specific streams.
code: def backward(
      ctx: Context,
      *grad_output: Tensor,
  ) -> Tuple[Optional[Tensor], ...]:
      prev_stream = ctx.prev_stream
      next_stream = ctx.next_stream
  
      grad_input: Deque[Tensor] = deque(maxlen=len(grad_output))
      input_stream = current_stream(get_device(prev_stream))
  
      with use_stream(prev_stream), use_stream(next_stream):
          for x in reversed(grad_output):
              y = x.to(get_device(prev_stream), non_blocking=True)
              grad_input.appendleft(y)
  
              # 'next_stream' is not where 'x' has been allocated.
              record_stream(x, next_stream)
              # 'y' has been allocated on 'prev_stream'.
              # It might be used on the current stream captured as 'input_stream'.
              record_stream(y, input_stream)
  
      grad_streams: Tuple[Optional[Tensor], ...] = (None, None)
      return grad_streams + tuple(grad_input)
  
file_path: fairscale/fairscale/nn/pipe/copy.py
imports: from collections import deque
  from typing import Deque, List, Optional, Tuple
  import torch
  from torch import Tensor
  from .stream import AbstractStream, current_stream, get_device, record_stream, use_stream, wait_stream
label_desc: Use image node_id 2 for calling the Copy obj's underlying member method code with example usage: obj.backward(ctx) and returns: unknown