class_docstr: PipelineHelper assists with implementing pipelining in model parallelism.
  
  For a tutorial on model parallelism, as it's implemented in parts of ParlAI,
  see https://pytorch.org/tutorials/intermediate/model_parallel_tutorial.html.
  
  Usage:
  >>> my_model = PipelineHelper().make_parallel(my_model)
  
  Note that you will need to manually implement logic which handles the
  moved layers.
class_docstr_tok: ["PipelineHelper","assists","with","implementing","pipelining","in","model","parallelism",".","For","a","tutorial","on","model","parallelism",",","as","it","'s","implemented","in","parts","of","ParlAI",",","see","https",":","\/\/pytorch.org\/tutorials\/intermediate\/model_parallel_tutorial.html",".","Usage",":",">",">",">","my_model","=","PipelineHelper","(",")",".make_parallel","(","my_model",")","Note","that","you","will","need","to","manually","implement","logic","which","handles","the","moved","layers","."]
docstr: Move the chunk to the device.
  
  Handles chunks which are groups of tensors.
docstr_tok: ["Move","the","chunk","to","the","device",".","Handles","chunks","which","are","groups","of","tensors","."]
code: def chunk_to(chunk: Chunk, device: str) -> Chunk:
      """
      Move the chunk to the device.
  
      Handles chunks which are groups of tensors.
      """
      if isinstance(chunk, torch.Tensor):
          return chunk.to(device)  # type: ignore
      elif isinstance(chunk, tuple):
          return tuple(
              PipelineHelper.chunk_to(c, device) for c in chunk
          )  # type: ignore
      elif isinstance(chunk, dict):
          return {
              k: PipelineHelper.chunk_to(v, device)
              for k, v in chunk.items()
          }  # type: ignore
      else:
          raise TypeError(
              "chunk_to only compatible with tensors, tuples or dicts."
          )
  
imports: import os
  from typing import Union, Optional, Tuple, Any, List, Sized, TypeVar
  import itertools
  from collections import namedtuple
  import parlai.utils.logging
  import parlai.utils.io
  import torch.optim
label_desc: Use image node_id 9 for calling the PipelineHelper obj's underlying member method code with example usage: obj.chunk_to(chunk, device) and returns: chunk, tuple, unknown