docstr: Initialize the backbone model from timm The backbone must already be loaded to self._backbone
docstr_tok: ["Initialize","the","backbone","model","from","timm","The","backbone","must","already","be","loaded","to","self._backbone"]
code: def _init_timm_backbone(self, config) -> None:
      """
      Initialize the backbone model from timm The backbone must already be loaded to self._backbone
      """
      if getattr(self, "_backbone", None) is None:
          raise ValueError(
              "self._backbone must be set before calling _init_timm_backbone"
          )
  
      # These will diagree with the defaults for the transformers models e.g. for resnet50
      # the transformer model has out_features = ['stem', 'stage1', 'stage2', 'stage3', 'stage4']
      # the timm model has out_features = ['act', 'layer1', 'layer2', 'layer3', 'layer4']
      self.stage_names = [
          stage["module"] for stage in self._backbone.feature_info.info
      ]
      self.num_features = [
          stage["num_chs"] for stage in self._backbone.feature_info.info
      ]
      out_indices = self._backbone.feature_info.out_indices
      out_features = self._backbone.feature_info.module_name()
  
      # We verify the out indices and out features are valid
      verify_out_features_out_indices(
          out_features=out_features,
          out_indices=out_indices,
          stage_names=self.stage_names,
      )
      self._out_features, self._out_indices = out_features, out_indices
  
imports: import enum
  import inspect
  from typing import Iterable, List, Optional, Tuple, Union
label_desc: Use image node_id 1 for calling the BackboneMixin obj's underlying member method code with example usage: obj._init_timm_backbone(config) without return types