class_docstr: Wraps an arbitrary :class:`nn.Sequential <torch.nn.Sequential>` module
  to train on Pipe_. If the module requires lots of memory, Pipe will be
  very efficient.
  ::
  
      model = nn.Sequential(a, b, c, d)
      model = Pipe(model, balance=[1, 1, 1, 1], chunks=8)
      output = model(input)
  
  .. _Pipe: https://arxiv.org/abs/1811.06965
  
  Pipe combines pipeline parallelism with checkpointing to reduce peak
  memory required to train while minimizing device under-utilization.
  
  You should determine the balance when defining a :class:`Pipe` module, as
  balancing will not be done automatically. The module will be partitioned
  into multiple devices according to the given balance. You may rely on
  heuristics to find your own optimal configuration.
  
  Args:
      module (torch.nn.Sequential):
          sequential module to be parallelized
      balance (ints):
          list of number of layers in each partition
  
  Keyword Args:
      devices (iterable of devices):
          devices to use (default: all CUDA devices)
      chunks (int):
          number of micro-batches (default: ``1``)
      checkpoint (str):
          when to enable checkpointing, one of ``'always'``,
          ``'except_last'``, or ``'never'`` (default: ``'except_last'``)
      deferred_batch_norm (bool):
          whether to use deferred BatchNorm moving statistics (default:
          :data:`False`, see :class:`Deferred Batch Normalization <DeferredBatchNorm>` for more
          details)
  
  Raises:
      TypeError:
          the module is not a :class:`nn.Sequential <torch.nn.Sequential>`.
      ValueError:
          invalid arguments, or wrong balance
      IndexError:
          the number of devices is fewer than the number of partitions.
class_docstr_tok: ["Wraps","an","arbitrary",":","class",":","`","nn.Sequential","<","torch.nn.Sequential",">","`","module","to","train","on","Pipe_",".","If","the","module","requires","lots","of","memory",",","Pipe","will","be","very","efficient",".",":",":","model","=","nn.Sequential","(","a",",","b",",","c",",","d",")","model","=","Pipe","(","model",",","balance=","[","1",",","1",",","1",",","1","]",",","chunks=8",")","output","=","model","(","input",")","..","_Pipe",":","https",":","\/\/arxiv.org\/abs\/1811.06965","Pipe","combines","pipeline","parallelism","with","checkpointing","to","reduce","peak","memory","required","to","train","while","minimizing","device","under-utilization",".","You","should","determine","the","balance","when","defining","a",":","class",":","`","Pipe","`","module",",","as","balancing","will","not","be","done","automatically",".","The","module","will","be","partitioned","into","multiple","devices","according","to","the","given","balance",".","You","may","rely","on","heuristics","to","find","your","own","optimal","configuration",".","Args",":","module","(","torch.nn.Sequential",")",":","sequential","module","to","be","parallelized","balance","(","ints",")",":","list","of","number","of","layers","in","each","partition","Keyword","Args",":","devices","(","iterable","of","devices",")",":","devices","to","use","(","default",":","all","CUDA","devices",")","chunks","(","int",")",":","number","of","micro-batches","(","default",":","``","1","``",")","checkpoint","(","str",")",":","when","to","enable","checkpointing",",","one","of","``","'always","'","``",",","``","'except_last","'","``",",","or","``","'never","'","``","(","default",":","``","'except_last","'","``",")","deferred_batch_norm","(","bool",")",":","whether","to","use","deferred","BatchNorm","moving","statistics","(","default",":",":","data",":","`","False","`",",","see",":","class",":","`","Deferred","Batch","Normalization","<","DeferredBatchNorm",">","`","for","more","details",")","Raises",":","TypeError",":","the","module","is","not","a",":","class",":","`","nn.Sequential","<","torch.nn.Sequential",">","`",".","ValueError",":","invalid","arguments",",","or","wrong","balance","IndexError",":","the","number","of","devices","is","fewer","than","the","number","of","partitions","."]
docstr: Deny these usages:
  - to(device[, dtype, non_blocking])
  - to(tensor[, non_blocking])
  
  But allow this:
  - to(dtype[, non_blocking])
docstr_tok: ["Deny","these","usages",":","-","to","(","device","[",",","dtype",",","non_blocking","]",")","-","to","(","tensor","[",",","non_blocking","]",")","But","allow","this",":","-","to","(","dtype","[",",","non_blocking","]",")"]
code: def to(self, *args: Any, **kwargs: Any) -> "Pipe":
      """Deny these usages:
      - to(device[, dtype, non_blocking])
      - to(tensor[, non_blocking])
  
      But allow this:
      - to(dtype[, non_blocking])"""
  
      if "device" in kwargs or "tensor" in kwargs:
          raise MOVING_DENIED
  
      if args:
          if isinstance(args[0], (torch.device, int, str)):
              raise MOVING_DENIED
          if torch.is_tensor(args[0]):
              raise MOVING_DENIED
  
      return super().to(*args, **kwargs)
  
imports: from collections import OrderedDict
  from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple, Union, cast
  import warnings
  import torch
  from torch import Tensor, nn
  import torch.autograd
  import torch.cuda
  from fairscale.internal import torch_version
  from .None import microbatch
  from .batchnorm import DeferredBatchNorm
  from .pipeline import Pipeline
  from .skip.layout import inspect_skip_layout
  from .skip.skippable import verify_skippables
  from .stream import AbstractStream, new_stream
label_desc: Use image node_id 7 for calling the Pipe obj's underlying member method code with example usage: obj.to() and returns: super