class_docstr: A base tuner for LyCORIS like adapters
class_docstr_tok: ["A","base","tuner","for","LyCORIS","like","adapters"]
code: def _replace_module(self, parent, child_name, new_module, child):
      setattr(parent, child_name, new_module)
      # It's not necessary to set requires_grad here, as that is handled by
      # _mark_only_adapters_as_trainable
  
      if not hasattr(new_module, "base_layer"):
          new_module.weight = child.weight
          if hasattr(child, "bias"):
              new_module.bias = child.bias
  
      if getattr(child, "state", None) is not None:
          if hasattr(new_module, "base_layer"):
              new_module.base_layer.state = child.state
          else:
              new_module.state = child.state
          new_module.to(child.weight.device)
  
      # dispatch to correct device
      for name, module in new_module.named_modules():
          if self.prefix in name:
              module.to(child.weight.device)
  
imports: from __future__ import annotations
  import warnings
  from abc import abstractmethod
  from dataclasses import dataclass, field
  from typing import Any, Dict, List, Optional, Set, Type, Union
  import torch
  import torch.nn
  from tqdm import tqdm
  from peft.config import PeftConfig
  from peft.utils import ModulesToSaveWrapper, _get_submodules
  from .tuners_utils import BaseTuner, BaseTunerLayer, check_target_module_exists
label_desc: Use image node_id 8 for calling the LycorisTuner obj's underlying member method code with example usage: obj._replace_module(parent, child_name, new_module, child) without return types