class_docstr: timm model adapter
  # FIXME this adapter is a work in progress, may change in ways that break weight compat
code: def __init__(
      self,
      model_name,
      embed_dim,
      image_size=224,
      pool="avg",
      proj="linear",
      drop=0.0,
      pretrained=False,
  ):
      super().__init__()
      if timm is None:
          raise RuntimeError(
              "Please `pip install timm` to use timm models."
          )
  
      self.image_size = to_2tuple(image_size)
      self.trunk = timm.create_model(model_name, pretrained=pretrained)
      feat_size = self.trunk.default_cfg.get("pool_size", None)
      feature_ndim = 1 if not feat_size else 2
      if pool in ("abs_attn", "rot_attn"):
          assert feature_ndim == 2
          # if attn pooling used, remove both classifier and default pool
          self.trunk.reset_classifier(0, global_pool="")
      else:
          # reset global pool if pool config set, otherwise leave as network default
          reset_kwargs = dict(global_pool=pool) if pool else {}
          self.trunk.reset_classifier(0, **reset_kwargs)
      prev_chs = self.trunk.num_features
  
      head_layers = OrderedDict()
      if pool == "abs_attn":
          head_layers["pool"] = AttentionPool2d(
              prev_chs, feat_size=feat_size, out_features=embed_dim
          )
          prev_chs = embed_dim
      elif pool == "rot_attn":
          head_layers["pool"] = RotAttentionPool2d(
              prev_chs, out_features=embed_dim
          )
          prev_chs = embed_dim
      else:
          assert (
              proj
          ), "projection layer needed if non-attention pooling is used."
  
      # NOTE attention pool ends with a projection layer, so proj should usually be set to '' if such pooling is used
      if proj == "linear":
          head_layers["drop"] = nn.Dropout(drop)
          head_layers["proj"] = nn.Linear(prev_chs, embed_dim)
      elif proj == "mlp":
          head_layers["mlp"] = Mlp(
              prev_chs, 2 * embed_dim, embed_dim, drop=drop
          )
  
      self.head = nn.Sequential(head_layers)
  
imports: import math
  import warnings
  from collections import OrderedDict
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  from torch import nn
  from lavis.models.clip_models.utils import freeze_batch_norm_2d
label_desc: Use image node_id 1 to create a new TimmModel object from inherited base classes: nn with example: obj = TimmModel(model_name, embed_dim, image_size, pool, proj, drop, pretrained)