





import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel





class 			A__   (							lowerCAmelCase__     ):




   """simple docstring"""



   __A       :    str	  =  "M-CLIP"

   def __init__( self ,  lowercase=1024 ,  lowercase=768 ,  **lowercase)      ->						Optional[int]:







          '''simple docstring'''

          a__						:     Dict			=    transformerDimSize
          a__						:     Optional[Any]			=    imageDimSize
          super().__init__(**_SCREAMING_SNAKE_CASE)





class 			A__   (							lowerCAmelCase__     ):




   """simple docstring"""



   __A       :    List[Any]	  =  MCLIPConfig

   def __init__( self ,  lowercase ,  *lowercase ,  **lowercase)      ->						Optional[int]:







          '''simple docstring'''

          super().__init__(_SCREAMING_SNAKE_CASE ,  *_SCREAMING_SNAKE_CASE ,  **_SCREAMING_SNAKE_CASE)
          a__						:     List[str]			=    XLMRobertaModel(_SCREAMING_SNAKE_CASE)
          a__						:     List[str]			=    torch.nn.Linear(
              in_features=config.transformerDimensions ,  out_features=config.numDims)

   def 							__lowercase		( self ,  lowercase ,  lowercase)      ->						Optional[Any]:







          '''simple docstring'''

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









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


lowercase				:	str      						=  {
    """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""", """VisionEncoderDecoderOnnxConfig"""]
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase				:	Optional[Any]      						=  ["""VisionEncoderDecoderModel"""]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase				:	Optional[int]      						=  ["""TFVisionEncoderDecoderModel"""]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase				:	List[str]      						=  ["""FlaxVisionEncoderDecoderModel"""]

if TYPE_CHECKING:
    from .configuration_vision_encoder_decoder import VisionEncoderDecoderConfig, VisionEncoderDecoderOnnxConfig

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_vision_encoder_decoder import VisionEncoderDecoderModel

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_vision_encoder_decoder import TFVisionEncoderDecoderModel

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_vision_encoder_decoder import FlaxVisionEncoderDecoderModel

else:
    import sys

    lowercase				:	Optional[int]      						=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


