class_docstr: <a id="PatchEmbeddings"></a>
  
  ## Get patch embeddings
  
  This splits the image into patches of size $p       imes p$ and gives an embedding for each patch.
class_docstr_tok: ["<","a","id=","''","PatchEmbeddings","''",">","<","\/a",">","#","#","Get","patch","embeddings","This","splits","the","image","into","patches","of","size","$","p","imes","p","$","and","gives","an","embedding","for","each","patch","."]
docstr: * `d_model` is the number of channels in patch embeddings $h$
  * `patch_size` is the size of the patch, $p$
  * `in_channels` is the number of channels in the input image (3 for rgb)
docstr_tok: ["*","`","d_model","`","is","the","number","of","channels","in","patch","embeddings","$","h","$","*","`","patch_size","`","is","the","size","of","the","patch",",","$","p","$","*","`","in_channels","`","is","the","number","of","channels","in","the","input","image","(","3","for","rgb",")"]
code: def __init__(self, d_model: int, patch_size: int, in_channels: int):
      """
      * `d_model` is the number of channels in patch embeddings $h$
      * `patch_size` is the size of the patch, $p$
      * `in_channels` is the number of channels in the input image (3 for rgb)
      """
      super().__init__()
  
      # We create a convolution layer with a kernel size and and stride length equal to patch size.
      # This is equivalent to splitting the image into patches and doing a linear
      # transformation on each patch.
      self.conv = nn.Conv2d(
          in_channels,
          d_model,
          kernel_size=patch_size,
          stride=patch_size,
      )
      # Activation function
      self.act = nn.GELU()
      # Batch normalization
      self.norm = nn.BatchNorm2d(d_model)
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/conv_mixer/__init__.py
imports: import torch
  from torch import nn
  from labml_helpers.module import Module
  from labml_nn.utils import clone_module_list
label_desc: Use image node_id 1 to create a new PatchEmbeddings object from inherited base classes: Module with example: obj = PatchEmbeddings(d_model, patch_size, in_channels)