code: def __init__(
      self,
      timm_encoder: Union[nn.Module, str],
      layers: List[int] = None,
      pretrained=True,
      **kwargs,
  ):
      strides = []
      channels = []
      default_layers = []
      if isinstance(timm_encoder, str):
          import timm.models.factory
  
          timm_encoder = timm.models.factory.create_model(
              timm_encoder,
              features_only=True,
              pretrained=pretrained,
              **kwargs,
          )
  
      for i, fi in enumerate(timm_encoder.feature_info):
          strides.append(fi["reduction"])
          channels.append(fi["num_chs"])
          default_layers.append(i)
  
      if layers is None:
          layers = default_layers
  
      super().__init__(channels, strides, layers)
      self.encoder = timm_encoder
  
file_path: pytorch-toolbelt/pytorch_toolbelt/modules/encoders/timm/common.py
imports: import math
  import warnings
  import torch
  from typing import List, Union
  from torch import Tensor, nn
  from ..common import EncoderModule, _take_ints, _take_tensors
label_desc: Use image node_id 1 to create a new GenericTimmEncoder object from inherited base classes: EncoderModule with example: obj = GenericTimmEncoder(timm_encoder, layers, pretrained)