class_docstr: Shard the original huggingface model according to the policy
  
  Args:
      policy (:class:`Policy`): The policy to shard the model
      model (:class:`torch.Module`): The model to shard
      shard_config: The setting of distributed model
docstr: Reverse the replace layer operation
  
  Args:
      module (torch.nn.Module): The object of layer to shard
      origin_cls (Union[str, torch.nn.Module]): The origin layer class or a string of layer class name
      attr_replacement (Dict[str, Any]): The attribute dict to modify
      param_replacement (List[Callable]): The function list to get parameter shard information in policy
      method_replacement (Dict[str, Callable]):  Key is the method name, value is the method for replacement
      sub_module_replacement ((List[SubModuleReplacementDescription]): The function list to get sub module shard information in policy
      include (Set[nn.Module], optional): The set of modules to keep on current device when pipeline parallel is enabled. Defaults to None
docstr_tok: ["Reverse","the","replace","layer","operation","Args",":","module","(","torch.nn.Module",")",":","The","object","of","layer","to","shard","origin_cls","(","Union","[","str",",","torch.nn.Module","]",")",":","The","origin","layer","class","or","a","string","of","layer","class","name","attr_replacement","(","Dict","[","str",",","Any","]",")",":","The","attribute","dict","to","modify","param_replacement","(","List","[","Callable","]",")",":","The","function","list","to","get","parameter","shard","information","in","policy","method_replacement","(","Dict","[","str",",","Callable","]",")",":","Key","is","the","method","name",",","value","is","the","method","for","replacement","sub_module_replacement","(","(","List","[","SubModuleReplacementDescription","]",")",":","The","function","list","to","get","sub","module","shard","information","in","policy","include","(","Set","[","nn.Module","]",",","optional",")",":","The","set","of","modules","to","keep","on","current","device","when","pipeline","parallel","is","enabled",".","Defaults","to","None"]
code: def _recursive_replace_layer(
      self,
      module: nn.Module,
      origin_cls: Union[str, nn.Module],
      attr_replacement: Dict[str, Any],
      param_replacement: List[Callable],
      method_replacement: Dict[str, Callable],
      sub_module_replacement: List[SubModuleReplacementDescription],
      include: Optional[Set[nn.Module]] = None,
  ) -> None:
      r"""
      Reverse the replace layer operation
  
      Args:
          module (torch.nn.Module): The object of layer to shard
          origin_cls (Union[str, torch.nn.Module]): The origin layer class or a string of layer class name
          attr_replacement (Dict[str, Any]): The attribute dict to modify
          param_replacement (List[Callable]): The function list to get parameter shard information in policy
          method_replacement (Dict[str, Callable]):  Key is the method name, value is the method for replacement
          sub_module_replacement ((List[SubModuleReplacementDescription]): The function list to get sub module shard information in policy
          include (Set[nn.Module], optional): The set of modules to keep on current device when pipeline parallel is enabled. Defaults to None
      """
      if (
          isinstance(origin_cls, str)
          and origin_cls == module.__class__.__name__
      ) or (module.__class__ == origin_cls):
          if attr_replacement is not None:
              self._replace_attr(module, attr_replacement)
  
          if param_replacement is not None and (
              include is None or module in include
          ):
              self._replace_param(module, param_replacement)
  
          if method_replacement is not None:
              self._replace_method(module, method_replacement)
  
          if sub_module_replacement is not None:
              self._replace_sub_module(
                  module, sub_module_replacement, include
              )
  
      for name, child in module.named_children():
          self._recursive_replace_layer(
              child,
              origin_cls,
              attr_replacement,
              param_replacement,
              method_replacement,
              sub_module_replacement,
              include=include,
          )
  
imports: from types import MethodType
  from typing import Any, Callable, Dict, List, Optional, Set, Union
  import torch.nn
  from torch import Tensor
  from colossalai.lazy import LazyInitContext
  from .._utils import getattr_, setattr_
  from ..policies.auto_policy import get_autopolicy
  from ..policies.base_policy import Policy, SubModuleReplacementDescription
  from .shard_config import ShardConfig
  from .utils import set_tensors_to_none
label_desc: Use image node_id 6 for calling the ModelSharder obj's underlying member method code with example usage: obj._recursive_replace_layer(module, origin_cls, attr_replacement, param_replacement, method_replacement, sub_module_replacement, include) without return types