






import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''M-CLIP'''
      def __init__(   self    ,	_lowerCAmelCase=1_024    ,	_lowerCAmelCase=768    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          lowerCAmelCase__   :Optional[int]      							=				transformerDimSize
          lowerCAmelCase__   :Any      							=				imageDimSize
          super().__init__(**_lowerCAmelCase		)







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    MCLIPConfig
      def __init__(   self    ,	_lowerCAmelCase    ,	*_lowerCAmelCase    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          super().__init__(_lowerCAmelCase    ,	*_lowerCAmelCase    ,	**_lowerCAmelCase		)
          lowerCAmelCase__   :Any      							=				XLMRobertaModel(_lowerCAmelCase		)
          lowerCAmelCase__   :Optional[int]      							=				torch.nn.Linear(
              in_features=config.transformerDimensions    ,	out_features=config.numDims		)



      def 			snake_case_      (   self    ,	_lowerCAmelCase    ,	_lowerCAmelCase		):



          '''simple docstring'''
          lowerCAmelCase__   :Optional[Any]      							=				self.transformer(input_ids=_lowerCAmelCase    ,	attention_mask=_lowerCAmelCase		)[0]
          lowerCAmelCase__   :str      							=				(embs * attention_mask.unsqueeze(2		)).sum(dim=1		) / attention_mask.sum(dim=1		)[:, None]
          return self.LinearTransformation(_lowerCAmelCase		), embs











from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_a    :   Tuple        =			logging.get_logger(__name__)

_a    :   Optional[int]        =			{
    """facebook/levit-128S""": """https://huggingface.co/facebook/levit-128S/resolve/main/config.json""",
    # See all LeViT models at https://huggingface.co/models?filter=levit
}







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''levit'''
      def __init__(   self    ,	_lowerCAmelCase=224    ,	_lowerCAmelCase=3    ,	_lowerCAmelCase=3    ,	_lowerCAmelCase=2    ,	_lowerCAmelCase=1    ,	_lowerCAmelCase=16    ,	_lowerCAmelCase=[128, 256, 384]    ,	_lowerCAmelCase=[4, 8, 12]    ,	_lowerCAmelCase=[4, 4, 4]    ,	_lowerCAmelCase=[16, 16, 16]    ,	_lowerCAmelCase=0    ,	_lowerCAmelCase=[2, 2, 2]    ,	_lowerCAmelCase=[2, 2, 2]    ,	_lowerCAmelCase=0.02    ,	**_lowerCAmelCase    ,	):



          '''simple docstring'''
          super().__init__(**_lowerCAmelCase		)
          lowerCAmelCase__   :List[str]      							=				image_size
          lowerCAmelCase__   :Dict      							=				num_channels
          lowerCAmelCase__   :List[Any]      							=				kernel_size
          lowerCAmelCase__   :List[Any]      							=				stride
          lowerCAmelCase__   :Tuple      							=				padding
          lowerCAmelCase__   :str      							=				hidden_sizes
          lowerCAmelCase__   :Union[str, Any]      							=				num_attention_heads
          lowerCAmelCase__   :Optional[int]      							=				depths
          lowerCAmelCase__   :Union[str, Any]      							=				key_dim
          lowerCAmelCase__   :str      							=				drop_path_rate
          lowerCAmelCase__   :int      							=				patch_size
          lowerCAmelCase__   :Dict      							=				attention_ratio
          lowerCAmelCase__   :Dict      							=				mlp_ratio
          lowerCAmelCase__   :Optional[int]      							=				initializer_range
          lowerCAmelCase__   :Tuple      							=				[
              ["Subsample", key_dim[0], hidden_sizes[0] // key_dim[0], 4, 2, 2],
              ["Subsample", key_dim[0], hidden_sizes[1] // key_dim[0], 4, 2, 2],
          ]







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    version.parse('''1.11'''		)
      @property
      def 			snake_case_      (   self		):



          '''simple docstring'''
          return OrderedDict(
              [
                  ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
              ]		)



      @property
      def 			snake_case_      (   self		):



          '''simple docstring'''
          return 1e-4



