class_docstr: Compute 2D patch embeddings with cls token and positional encoding
code: def forward(self, x: torch.Tensor) -> torch.Tensor:
      B, C, H, W = x.shape
      assert (
          H % self.patch_size[0] == 0
      ), "Image height must be divisible by patch height"
      assert (
          W % self.patch_size[1] == 0
      ), "Image width must be divisible by patch width"
  
      # patchify image
      patches = self.projection(x).flatten(2).transpose(1, 2)
  
      cls_tokens = self.cls_token.expand(
          B, -1, -1
      )  # (batch_size, 1, d_model)
      # concate cls_tokens to patches
      embeddings = torch.cat(
          [cls_tokens, patches], dim=1
      )  # (batch_size, num_patches + 1, d_model)
      # add positions to embeddings
      if self.interpolate:
          embeddings += self.interpolate_pos_encoding(embeddings, H, W)
      else:
          embeddings += self.positions
  
      return embeddings
  
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 3 for calling the PatchEmbedding obj's underlying member method code with example usage: obj.forward(x) and returns: embeddings