class_docstr: 2D Image to Patch Embedding
      
class_docstr_tok: ["2D","Image","to","Patch","Embedding"]
code: def forward(self, x):
      B, C, H, W = x.shape
      if self.img_size is not None:
          if self.strict_img_size:
              _assert(
                  H == self.img_size[0],
                  f"Input height ({H}) doesn't match model ({self.img_size[0]}).",
              )
              _assert(
                  W == self.img_size[1],
                  f"Input width ({W}) doesn't match model ({self.img_size[1]}).",
              )
          elif not self.dynamic_img_pad:
              _assert(
                  H % self.patch_size[0] == 0,
                  f"Input height ({H}) should be divisible by patch size ({self.patch_size[0]}).",
              )
              _assert(
                  W % self.patch_size[1] == 0,
                  f"Input width ({W}) should be divisible by patch size ({self.patch_size[1]}).",
              )
      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)
      x = self.norm(x)
      return x
  
file_path: pytorch-image-models/timm/layers/patch_embed.py
imports: import logging
  from typing import Callable, List, Optional, Tuple, Union
  import torch
  from torch import nn
  import torch.nn.functional
  from .format import Format, nchw_to
  from .helpers import to_2tuple
  from .trace_utils import _assert
label_desc: Use image node_id 2 for calling the PatchEmbed obj's underlying member method code with example usage: obj.forward(x) and returns: x