



"""simple docstring"""
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel


class    SCREAMING_SNAKE_CASE__ (							__SCREAMING_SNAKE_CASE   ):
    lowercase__      =   "M-CLIP"

    def __init__(				self			:				int ,  lowerCAmelCase_			:				str=1_0_2_4 ,  lowerCAmelCase_			:				str=7_6_8 ,  **lowerCAmelCase_			:				Optional[Any]):







      """simple docstring"""







      lowercase_								= transformerDimSize
      lowercase_								= imageDimSize
      super().__init__(**_a)







class    SCREAMING_SNAKE_CASE__ (							__SCREAMING_SNAKE_CASE   ):
    lowercase__      =   MCLIPConfig

    def __init__(				self			:				Optional[Any] ,  lowerCAmelCase_			:				List[Any] ,  *lowerCAmelCase_			:				str ,  **lowerCAmelCase_			:				List[Any]):







      """simple docstring"""







      super().__init__(_a ,  *_a ,  **_a)
      lowercase_								= XLMRobertaModel(_a)
      lowercase_								= torch.nn.Linear(
          in_features=config.transformerDimensions ,  out_features=config.numDims)




    def 					_UpperCAmelCase	(				self			:				int ,  lowerCAmelCase_			:				int ,  lowerCAmelCase_			:				Any):







      """simple docstring"""







      lowercase_								= self.transformer(input_ids=_a ,  attention_mask=_a)[0]
      lowercase_								= (embs * attention_mask.unsqueeze(2)).sum(dim=1) / attention_mask.sum(dim=1)[:, None]
      return self.LinearTransformation(_a), embs






"""simple docstring"""
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCAmelCase						:		Optional[Any]			= {"configuration_wavlm": ["WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "WavLMConfig"]}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase						:		str			= [
           "WAVLM_PRETRAINED_MODEL_ARCHIVE_LIST",
           "WavLMForAudioFrameClassification",
           "WavLMForCTC",
           "WavLMForSequenceClassification",
           "WavLMForXVector",
           "WavLMModel",
           "WavLMPreTrainedModel",
       ]

if TYPE_CHECKING:
       from .configuration_wavlm import WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP, WavLMConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_wavlm import (
                  WAVLM_PRETRAINED_MODEL_ARCHIVE_LIST,
                  WavLMForAudioFrameClassification,
                  WavLMForCTC,
                  WavLMForSequenceClassification,
                  WavLMForXVector,
                  WavLMModel,
                  WavLMPreTrainedModel,
              )

else:
       import sys

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

