class_docstr: 2D Image to Patch Embedding
class_docstr_tok: ["2D","Image","to","Patch","Embedding"]
code: def forward(self, pixel_values):
      batch_size, channel, height, width = pixel_values.shape
      if height != self.image_size[0] or width != self.image_size[1]:
          raise ValueError(
              f"Input image size ({height}*{width}) doesn't match model ({self.image_size[0]}*{self.image_size[1]})."
          )
  
      patch_embeddings = self.proj(pixel_values)
      patch_embeddings = patch_embeddings.flatten(2).transpose(
          1, 2
      )  # BCHW -> BNC
  
      cls_tokens = self.cls_token.expand(batch_size, -1, -1)
      embedding_output = torch.cat(
          (cls_tokens, patch_embeddings), dim=1
      )
      embedding_output = embedding_output + self.pos_embed
      embedding_output = self.pos_drop(embedding_output)
  
      return embedding_output
  
imports: import collections.abc
  from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch import nn
  from ...modeling_outputs import BaseModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import ModelOutput, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_mgp_str import MgpstrConfig
label_desc: Use image node_id 2 for calling the MgpstrEmbeddings obj's underlying member method code with example usage: obj.forward(pixel_values) and returns: embedding_output