class_docstr: A context manager to split the model into pipeline stages.
class_docstr_tok: ["A","context","manager","to","split","the","model","into","pipeline","stages","."]
docstr: Create a layer spec list and func list with execution sequence given by user.
  If exec_seq is None, we will take the module initializing order as execution order.
docstr_tok: ["Create","a","layer","spec","list","and","func","list","with","execution","sequence","given","by","user",".","If","exec_seq","is","None",",","we","will","take","the","module","initializing","order","as","execution","order","."]
code: def to_layer_list(self, exec_seq=None):
      """
      Create a layer spec list and func list with execution sequence given by user.
      If exec_seq is None, we will take the module initializing order as execution order.
      """
  
      self._exec_seq = exec_seq
      if exec_seq is None:
          # if user do not provide the model executing sequence, we use the initialization order as the executing order.
          children_name = []
          for child in self._root_children:
              layer_spec = self._layer_spec_dict[id(child)]
              if layer_spec.typename in (
                  torch.nn.modules.container.ModuleList,
                  torch.nn.modules.container.Sequential,
              ):
                  for child_in_container in layer_spec.children:
                      self._layer_spec_list.append(
                          self._layer_spec_dict[id(child_in_container)]
                      )
                      for name, module in self._model.named_modules():
                          if id(module) == id(child_in_container):
                              children_name.append(name)
                              break
              else:
                  self._layer_spec_list.append(layer_spec)
                  for name, module in self._model.named_modules():
                      if id(module) == id(child):
                          children_name.append(name)
                          break
  
      else:
          front_funcs_list = []
          named_modules = dict(self._model.named_modules())
          for index, element in enumerate(exec_seq):
              if isinstance(element, str):
                  if element == "SPLIT_NODE":
                      continue
                  assert (
                      element in named_modules
                  ), f"Found invalid module name {element}, please check if you spell the module name correctly."
  
                  # get the layer spec based on the module ID
                  module = named_modules[element]
                  layer_spec = self._layer_spec_dict[id(module)]
  
                  # check whether there are functions which should be executed before this module
                  if len(front_funcs_list) != 0:
                      func_key = (layer_spec, "front")
                      if func_key not in self._func_dict:
                          self._func_dict[func_key] = []
                      for f in front_funcs_list:
                          self._func_dict[func_key].append(f)
                      front_funcs_list = []
  
                  func_key = (layer_spec, "behind")
                  self._layer_spec_list.append(layer_spec)
              elif isinstance(element, tuple) and element[1] == "front":
                  front_funcs_list.append(element[0])
              else:
                  if func_key not in self._func_dict:
                      self._func_dict[func_key] = []
                  if isinstance(element, tuple):
                      self._func_dict[func_key].append(element[0])
                  else:
                      self._func_dict[func_key].append(element)
  
imports: import torch
  from colossalai.legacy.context import ParallelMode
  from colossalai.legacy.core import global_context
  from colossalai.legacy.nn.layer.utils import CheckpointModule
  from colossalai.tensor import ColoParameter
  from colossalai.utils.model.utils import InsertPostInitMethodToModuleSubClasses
  from .layer_spec import LayerSpec
  from .utils import build_kwargs_for_module, call_module, customized_partition, exec_funcs_with_kwargs, partition_balanced, partition_uniform
label_desc: Use image node_id 9 for calling the PipelinableContext obj's underlying member method code with example usage: obj.to_layer_list(exec_seq) without return types