class_docstr: CNN Feature Map Embedding
  Extract feature map from CNN, flatten, project to embedding dim.
class_docstr_tok: ["CNN","Feature","Map","Embedding","Extract","feature","map","from","CNN",",","flatten",",","project","to","embedding","dim","."]
code: def forward(self, x):
      x = self.backbone(x)
      if isinstance(x, (list, tuple)):
          x = x[
              -1
          ]  # last feature if backbone outputs list/tuple of features
      _, _, H, W = x.shape
      if self.dynamic_img_pad:
          pad_h = (
              self.patch_size[0] - H % self.patch_size[0]
          ) % self.patch_size[0]
          pad_w = (
              self.patch_size[1] - W % self.patch_size[1]
          ) % self.patch_size[1]
          x = F.pad(x, (0, pad_w, 0, pad_h))
      x = self.proj(x)
      if self.flatten:
          x = x.flatten(2).transpose(1, 2)  # NCHW -> NLC
      elif self.output_fmt != Format.NCHW:
          x = nchw_to(x, self.output_fmt)
      return x
  
imports: from functools import partial
  from typing import List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import StdConv2dSame, StdConv2d, to_2tuple, Format, nchw_to
  from ._registry import generate_default_cfgs, register_model, register_model_deprecations
  from .resnet import resnet26d, resnet50d
  from .resnetv2 import ResNetV2, create_resnetv2_stem
  from .vision_transformer import _create_vision_transformer, VisionTransformer
label_desc: Use image node_id 2 for calling the HybridEmbed obj's underlying member method code with example usage: obj.forward(x) and returns: x