class_docstr: Compute the 2d image patch embedding ready to pass to transformer encoder.
code: def __init__(
      self,
      in_channels: int = 3,
      out_channels: int = 768,
      patch_size: int = 16,
      image_size: int = 224,
      backbone: Optional[Module] = None,
  ) -> None:
      super().__init__()
      self.in_channels = in_channels
      self.out_channels = out_channels
      self.patch_size = patch_size
  
      # logic needed in case a backbone is passed
      self.backbone = backbone or nn.Conv2d(
          in_channels,
          out_channels,
          kernel_size=patch_size,
          stride=patch_size,
      )
      if backbone is not None:
          out_channels, feat_size = self._compute_feats_dims(
              (in_channels, image_size, image_size)
          )
          self.out_channels = out_channels
      else:
          feat_size = (image_size // patch_size) ** 2
  
      self.cls_token = nn.Parameter(torch.randn(1, 1, out_channels))
      self.positions = nn.Parameter(
          torch.randn(feat_size + 1, out_channels)
      )
  
imports: from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from kornia.core import Module, Tensor
label_desc: Use image node_id 1 to create a new PatchEmbedding object from inherited base classes: Module with example: obj = PatchEmbedding(in_channels, out_channels, patch_size, image_size, backbone)