




import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Audio, ClassLabel, Features
from .base import TaskTemplate
@dataclass(frozen=snake_case__   )
class     a__					(      snake_case__   ):
						_a							:					str      =					field(default="""audio-classification"""				,       metadata={"""include_in_asdict_even_if_is_default""": True}   )
						_a							:					ClassVar[Features]      =					Features({"""audio""": Audio()}   )
						_a							:					ClassVar[Features]      =					Features({"""labels""": ClassLabel}   )
						_a							:					str      =					"audio"
						_a							:					str      =					"labels"






						def        __SCREAMING_SNAKE_CASE(     self	,    _A    ):




											"""simple docstring"""



											if self.label_column not in features:
																raise ValueError(f"""Column {self.label_column} is not present in features."""    )
											if not isinstance(features[self.label_column]	,    _A    ):
																raise ValueError(f"""Column {self.label_column} is not a ClassLabel."""    )
											__lowerCAmelCase            = copy.deepcopy(self    )
											__lowerCAmelCase            = self.label_schema.copy()
											__lowerCAmelCase            = features[self.label_column]
											__lowerCAmelCase            = label_schema
											return task_template






						@property
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											return {
											    self.audio_column: "audio",
											    self.label_column: "labels",
											}










import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class     a__					(      snake_case__   ):
						_a							:					Optional[Any]      =					"""M-CLIP"""






						def __init__(     self	,    _A=1_0_2_4	,    _A=7_6_8	,    **_A    ):




											"""simple docstring"""



											__lowerCAmelCase            = transformerDimSize
											__lowerCAmelCase            = imageDimSize
											super().__init__(**_A    )






class     a__					(      snake_case__   ):
						_a							:					Tuple      =					MCLIPConfig






						def __init__(     self	,    _A	,    *_A	,    **_A    ):




											"""simple docstring"""



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






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A    ):




											"""simple docstring"""



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




