class_docstr: Compute 2D patch embeddings with cls token and positional encoding
code: def __init__(
      self,
      input_shape: Tuple[int, int, int],
      embed_dim: int,
      patch_size: Tuple[int, int],
  ) -> None:
      super().__init__()
      channels, height, width = input_shape
      self.patch_size = patch_size
      self.interpolate = (
          True if patch_size[0] == patch_size[1] else False
      )
      self.grid_size = tuple(
          [s // p for s, p in zip((height, width), self.patch_size)]
      )
      self.num_patches = self.grid_size[0] * self.grid_size[1]
  
      self.cls_token = nn.Parameter(torch.randn(1, 1, embed_dim))
      self.positions = nn.Parameter(
          torch.randn(1, self.num_patches + 1, embed_dim)
      )
      self.projection = nn.Conv2d(
          channels,
          embed_dim,
          kernel_size=self.patch_size,
          stride=self.patch_size,
      )
  
file_path: doctr/doctr/models/modules/vision_transformer/pytorch.py
imports: import math
  from typing import Tuple
  import torch
  from torch import nn
label_desc: Use image node_id 1 to create a new PatchEmbedding object from inherited base classes: nn with example: obj = PatchEmbedding(input_shape, embed_dim, patch_size)