src/transformers/models/vit_hybrid/modeling_vit_hybrid.py/ViTHybridPatchEmbeddings/__init__
class ViTHybridPatchEmbeddings:    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)