code: def __init__(
      self, model: nn.Module, return_layers: Dict[str, str]
  ) -> None:
      all_named_children = list(model.named_children())
      invalid_names = check_named_children(
          all_named_children, return_layers
      )
      if invalid_names:
          all_named_children = []
          inject_all_named_children(model, all_named_children, None)
          all_names = set(name for name, _ in all_named_children)
          invalid_names = []
          for layer in return_layers:
              if layer not in all_names:
                  invalid_names.append(layer)
          if invalid_names:
              invalid_msg = ", ".join(invalid_names)
              raise ValueError(
                  f"following layers: {invalid_msg} are not presented"
              )
      name_mapping = {
          k: str(i) for i, (k, _) in enumerate(all_named_children)
      }
      all_named_children = [
          (name_mapping[k], m) for k, m in all_named_children
      ]
      return_layers = {
          name_mapping[k]: v for k, v in return_layers.items()
      }
      orig_return_layers = return_layers
      return_layers = {str(k): str(v) for k, v in return_layers.items()}
      layers = OrderedDict()
      for name, module in all_named_children:
          layers[name] = module
          if name in return_layers:
              del return_layers[name]
          if not return_layers:
              break
      super().__init__(layers)
      self.return_layers = orig_return_layers
  
imports: import torch
  from torch import nn
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Optional
  from collections import OrderedDict
  from cftool.types import tensor_dict_type
  from .register import backbone_info_dict
  from .....constants import LATENT_KEY
  from .....misc.toolkit import set_requires_grad
label_desc: Use image node_id 1 to create a new IntermediateLayerGetter object from inherited base classes: nn with example: obj = IntermediateLayerGetter(model, return_layers)