class_docstr: This class turns `pixel_values` of shape `(batch_size, num_channels, height, width)` into the initial
  `hidden_states` (patch embeddings) of shape `(batch_size, seq_length, hidden_size)` to be consumed by a
  Transformer.
class_docstr_tok: ["This","class","turns","`","pixel_values","`","of","shape","`","(","batch_size",",","num_channels",",","height",",","width",")","`","into","the","initial","`","hidden_states","`","(","patch","embeddings",")","of","shape","`","(","batch_size",",","seq_length",",","hidden_size",")","`","to","be","consumed","by","a","Transformer","."]
code: def __init__(self, config, feature_size=None):
      super().__init__()
      image_size, patch_size = config.image_size, config.patch_size
      num_channels, hidden_size = (
          config.num_channels,
          config.hidden_size,
      )
  
      image_size = (
          image_size
          if isinstance(image_size, collections.abc.Iterable)
          else (image_size, image_size)
      )
      patch_size = (
          patch_size
          if isinstance(patch_size, collections.abc.Iterable)
          else (patch_size, patch_size)
      )
  
      self.backbone = AutoBackbone.from_config(config.backbone_config)
      if self.backbone.config.model_type != "bit":
          raise ValueError(
              f"Backbone model type {self.backbone.model_type} is not supported."
          )
      feature_dim = self.backbone.channels[-1]
  
      if feature_size is None:
          feature_map = config.backbone_featmap_shape
  
          feature_size = feature_map[-2:]
          feature_dim = feature_map[1]
      else:
          feature_size = (
              feature_size
              if isinstance(feature_size, collections.abc.Iterable)
              else (feature_size, feature_size)
          )
          feature_dim = self.backbone.channels[-1]
  
      self.grid_size = (
          feature_size[0] // patch_size[0],
          feature_size[1] // patch_size[1],
      )
      self.num_patches = self.grid_size[0] * self.grid_size[1]
      self.image_size = image_size
      self.patch_size = patch_size
      self.num_channels = num_channels
  
      self.projection = nn.Conv2d(
          feature_dim,
          hidden_size,
          kernel_size=patch_size,
          stride=patch_size,
      )
  
imports: import collections.abc
  import math
  from typing import Dict, List, Optional, Set, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, ImageClassifierOutput
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from ..auto import AutoBackbone
  from .configuration_vit_hybrid import ViTHybridConfig
label_desc: Use image node_id 1 to create a new ViTHybridPatchEmbeddings object from inherited base classes: nn with example: obj = ViTHybridPatchEmbeddings(config, feature_size)