class_docstr: 2D Image to Patch Embedding
class_docstr_tok: ["2D","Image","to","Patch","Embedding"]
code: def __init__(
      self,
      height=224,
      width=224,
      patch_size=16,
      in_channels=3,
      embed_dim=768,
      layer_norm=False,
      flatten=True,
      bias=True,
      use_pos_embed=True,
  ):
      super().__init__()
  
      num_patches = (height // patch_size) * (width // patch_size)
      self.flatten = flatten
      self.layer_norm = layer_norm
  
      self.proj = nn.Conv2d(
          in_channels,
          embed_dim,
          kernel_size=(patch_size, patch_size),
          stride=patch_size,
          bias=bias,
      )
      if layer_norm:
          self.norm = nn.LayerNorm(
              embed_dim, elementwise_affine=False, eps=1e-6
          )
      else:
          self.norm = None
  
      self.use_pos_embed = use_pos_embed
      if self.use_pos_embed:
          pos_embed = get_2d_sincos_pos_embed(
              embed_dim, int(num_patches**0.5)
          )
          self.register_buffer(
              "pos_embed",
              torch.from_numpy(pos_embed).float().unsqueeze(0),
              persistent=False,
          )
  
imports: import math
  from typing import Optional, Union
  import torch
  from torch import nn
  from ...configuration_utils import ConfigMixin, register_to_config
  from ...models import ModelMixin
  from ...models.attention import AdaLayerNorm, FeedForward
  from ...models.attention_processor import Attention
  from ...models.embeddings import TimestepEmbedding, Timesteps, get_2d_sincos_pos_embed
  from ...models.transformer_2d import Transformer2DModelOutput
  from ...utils import logging
label_desc: Use image node_id 1 to create a new PatchEmbed object from inherited base classes: nn with example: obj = PatchEmbed(height, width, patch_size, in_channels, embed_dim, layer_norm, flatten, bias, use_pos_embed)