class_docstr: Compute 2D patch embeddings with cls token and positional encoding
class_docstr_tok: ["Compute","2D","patch","embeddings","with","cls","token","and","positional","encoding"]
code: def call(self, x: tf.Tensor, **kwargs: Any) -> tf.Tensor:
      B, H, W, C = 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, **kwargs
      )  # (batch_size, num_patches, d_model)
      patches = tf.reshape(
          patches, (B, self.num_patches, -1)
      )  # (batch_size, num_patches, d_model)
  
      cls_tokens = tf.repeat(
          self.cls_token, B, axis=0
      )  # (batch_size, 1, d_model)
      # concate cls_tokens to patches
      embeddings = tf.concat(
          [cls_tokens, patches], axis=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/tensorflow.py
imports: import math
  from typing import Any, Tuple
  import tensorflow
  from tensorflow.keras import layers
  from doctr.utils.repr import NestedObject
label_desc: Use image node_id 3 for calling the PatchEmbedding obj's underlying member method code with example usage: obj.call(x) and returns: embeddings