






import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel




class 			snake_case__   (							lowercase_):

       '''simple docstring'''
       lowerCamelCase							:				str 				= "M-CLIP"



       def __init__(							self			,						a__=10_24			,						a__=7_68			,						**a__    ) ->      str:






            '''simple docstring'''





            __snake_case			:str          =						transformerDimSize
            __snake_case			:Union[str, Any]          =						imageDimSize
            super().__init__(**a__    )




class 			snake_case__   (							lowercase_):

       '''simple docstring'''
       lowerCamelCase							:				List[str] 				= MCLIPConfig



       def __init__(							self			,						a__			,						*a__			,						**a__    ) ->      str:






            '''simple docstring'''





            super().__init__(a__			,						*a__			,						**a__    )
            __snake_case			:Union[str, Any]          =						XLMRobertaModel(a__    )
            __snake_case			:Tuple          =						torch.nn.Linear(
                in_features=config.transformerDimensions			,						out_features=config.numDims    )



       def 					__lowercase						(							self			,						a__			,						a__    ) ->      Union[str, Any]:






            '''simple docstring'''





            __snake_case			:Optional[int]          =						self.transformer(input_ids=a__			,						attention_mask=a__    )[0]
            __snake_case			:str          =						(embs * attention_mask.unsqueeze(2    )).sum(dim=1    ) / attention_mask.sum(dim=1    )[:, None]
            return self.LinearTransformation(a__    ), embs










from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available
from ...utils import OptionalDependencyNotAvailable


lowerCamelCase__							=     {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfig"""]}

try:
     if not is_vision_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase__							=     ["""DPTFeatureExtractor"""]
     lowerCamelCase__							=     ["""DPTImageProcessor"""]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase__							=     [
         """DPT_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """DPTForDepthEstimation""",
         """DPTForSemanticSegmentation""",
         """DPTModel""",
         """DPTPreTrainedModel""",
     ]


if TYPE_CHECKING:
     from .configuration_dpt import DPT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPTConfig

     try:
          if not is_vision_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .feature_extraction_dpt import DPTFeatureExtractor
          from .image_processing_dpt import DPTImageProcessor

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_dpt import (
              DPT_PRETRAINED_MODEL_ARCHIVE_LIST,
              DPTForDepthEstimation,
              DPTForSemanticSegmentation,
              DPTModel,
              DPTPreTrainedModel,
          )


else:
     import sys

     lowerCamelCase__							=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


