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 __init__(
      self,
      backbone,
      img_size=224,
      feature_size=None,
      in_chans=3,
      embed_dim=768,
  ):
      super().__init__()
      assert isinstance(backbone, nn.Module)
      img_size = to_2tuple(img_size)
      self.img_size = img_size
      self.backbone = backbone
      if feature_size is None:
          with torch.no_grad():
              # FIXME this is hacky, but most reliable way of determining the
              # exact dim of the output feature map for all networks,
              # the feature metadata has reliable channel and stride info,
              # but using stride to calc feature dim requires info about
              # padding of each stage that isn't captured.
              training = backbone.training
              if training:
                  backbone.eval()
              o = self.backbone(
                  torch.zeros(1, in_chans, img_size[0], img_size[1])
              )[-1]
              feature_size = o.shape[-2:]
              feature_dim = o.shape[1]
              backbone.train(training)
      else:
          feature_size = to_2tuple(feature_size)
          feature_dim = self.backbone.feature_info.channels()[-1]
      self.num_patches = feature_size[0] * feature_size[1]
      self.proj = nn.Linear(feature_dim, embed_dim)
      self.apply(self._init_weights)
  
imports: import copy
  import logging
  import math
  import torch
  import torch.nn
  from vissl.models.model_helpers import DropPath, to_2tuple, trunc_normal_
  from vissl.models.trunks import register_model_trunk
  from vissl.utils.hydra_config import AttrDict
label_desc: Use image node_id 1 to create a new HybridEmbed object from inherited base classes: nn with example: obj = HybridEmbed(backbone, img_size, feature_size, in_chans, embed_dim)