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: Join chunks back together, the inverse of split.
  
  :param items:
      All the output chunks. Each chunk may be a tensor or a group of
      tensors.
  :param dim:
      The dimension to join along.
docstr_tok: ["Join","chunks","back","together",",","the","inverse","of","split",".",":","param","items",":","All","the","output","chunks",".","Each","chunk","may","be","a","tensor","or","a","group","of","tensors",".",":","param","dim",":","The","dimension","to","join","along","."]
code: def join(items: List[Chunk], dim=0) -> Chunk:
      """
      Join chunks back together, the inverse of split.
  
      :param items:
          All the output chunks. Each chunk may be a tensor or a group of
          tensors.
      :param dim:
          The dimension to join along.
      """
      if len(items) == 0:
          raise IndexError("Cannot rejoin an empty list of chunks.")
      item0 = items[0]
      if isinstance(item0, torch.Tensor):
          # base case
          return torch.cat(items, dim=dim)  # type: ignore
      elif isinstance(item0, tuple):
          return tuple(
              PipelineHelper.join(x, dim=dim) for x in zip(*items)
          )  # type: ignore
      elif isinstance(item0, dict):
          keys = item0.keys()
          return {  # type: ignore
              k: PipelineHelper.join([c[k] for c in items], dim=dim)  # type: ignore
              for k in keys
          }
      else:
          raise TypeError(f"Cannot join list of type {type(item0)}")
  
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 8 for calling the PipelineHelper obj's underlying member method code with example usage: obj.join(items, dim) and returns: torch, tuple, unknown