class_docstr: Building block for specifying pipeline-parallel modules.
  
  LayerSpec stores the type information and parameters for each stage in a
  PipelineModule. For example:
  
  .. code-block:: python
  
      nn.Sequence(
          torch.nn.Linear(self.in_dim, self.hidden_dim, bias=False),
          torch.nn.Linear(self.hidden_hidden, self.out_dim)
      )
  
  becomes
  
  .. code-block:: python
  
      layer_specs = [
          LayerSpec(torch.nn.Linear, self.in_dim, self.hidden_dim, bias=False),
          LayerSpec(torch.nn.Linear, self.hidden_hidden, self.out_dim)]
      ]
class_docstr_tok: ["Building","block","for","specifying","pipeline-parallel","modules",".","LayerSpec","stores","the","type","information","and","parameters","for","each","stage","in","a","PipelineModule",".","For","example",":","..","code-block",":",":","python","nn.Sequence","(","torch.nn.Linear","(","self.in_dim",",","self.hidden_dim",",","bias=False",")",",","torch.nn.Linear","(","self.hidden_hidden",",","self.out_dim",")",")","becomes","..","code-block",":",":","python","layer_specs","=","[","LayerSpec","(","torch.nn.Linear",",","self.in_dim",",","self.hidden_dim",",","bias=False",")",",","LayerSpec","(","torch.nn.Linear",",","self.hidden_hidden",",","self.out_dim",")","]","]"]
docstr: Build the stored specification.
docstr_tok: ["Build","the","stored","specification","."]
code: def build(self, log=False):
      """Build the stored specification."""
      if log:
          logger.info(f"RANK={self.global_rank} building {repr(self)}")
  
      return self.typename(*self.module_args, **self.module_kwargs)
  
imports: import os
  import glob
  import re
  from functools import partial
  import torch
  import torch.nn
  from deepspeed import comm
  from deepspeed.utils import logger
  from ..None import utils
  from ..activation_checkpointing import checkpointing
  from .topology import PipeDataParallelTopology, PipelineParallelGrid
  from deepspeed.runtime.state_dict_factory import SDLoaderFactory
  from deepspeed.accelerator import get_accelerator
  from deepspeed.checkpoint.utils import clone_tensors_for_torch_save
label_desc: Use image node_id 3 for calling the LayerSpec obj's underlying member method code with example usage: obj.build(log) and returns: self