class_docstr: Image to Patch Embedding
class_docstr_tok: ["Image","to","Patch","Embedding"]
code: def __init__(
      self, img_size=224, patch_size=16, in_chans=3, embed_dim=768
  ):
      super().__init__()
      if isinstance(img_size, int):
          img_size = img_size, img_size
      if isinstance(patch_size, int):
          patch_size = patch_size, patch_size
      num_patches = (img_size[1] // patch_size[1]) * (
          img_size[0] // patch_size[0]
      )
      self.patch_shape = (
          img_size[0] // patch_size[0],
          img_size[1] // patch_size[1],
      )
      self.img_size = img_size
      self.patch_size = patch_size
      self.num_patches = num_patches
  
      self.conv = nn.Conv2d(
          in_chans, embed_dim, kernel_size=patch_size, stride=patch_size
      )
  
imports: import logging
  import math
  import numpy
  import random
  from dataclasses import dataclass, field
  from typing import Optional
  from omegaconf import II
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.distributed
  from fairseq.modules import EMAModule, EMAModuleConfig
  from fairseq.dataclass import FairseqDataclass
  from fairseq.models import BaseFairseqModel, register_model
label_desc: Use image node_id 1 to create a new PatchEmbed object from inherited base classes: nn with example: obj = PatchEmbed(img_size, patch_size, in_chans, embed_dim)