



'''simple docstring'''





import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel

class 	lowerCamelCase_    ( _A						):






						'''simple docstring'''
						a__   =  "M-CLIP"







						def __init__(	self      :			Dict	,	__lowerCamelCase      :			List[str]=10_24	,	__lowerCamelCase      :			Optional[Any]=7_68	,	**__lowerCamelCase      :			List[Any] )      ->				Optional[int]:
									A							:					List[str]              =						transformerDimSize
									A							:					Dict              =						imageDimSize
									super().__init__(**__lowerCamelCase )







class 	lowerCamelCase_    ( _A						):






						'''simple docstring'''
						a__   =  MCLIPConfig







						def __init__(	self      :			Optional[int]	,	__lowerCamelCase      :			Optional[int]	,	*__lowerCamelCase      :			Any	,	**__lowerCamelCase      :			Union[str, Any] )      ->				Optional[Any]:
									super().__init__(__lowerCamelCase	,	*__lowerCamelCase	,	**__lowerCamelCase )
									A							:					Dict              =						XLMRobertaModel(__lowerCamelCase )
									A							:					List[str]              =						torch.nn.Linear(
									    in_features=config.transformerDimensions	,	out_features=config.numDims )







						def 			SCREAMING_SNAKE_CASE__		(	self      :			Any	,	__lowerCamelCase      :			List[Any]	,	__lowerCamelCase      :			Any )      ->				int:
									A							:					Any              =						self.transformer(input_ids=__lowerCamelCase	,	attention_mask=__lowerCamelCase )[0]
									A							:					Any              =						(embs * attention_mask.unsqueeze(2 )).sum(dim=1 ) / attention_mask.sum(dim=1 )[:, None]
									return self.LinearTransformation(__lowerCamelCase ), embs




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

from ..features import Features, Sequence, Value
from .base import TaskTemplate

@dataclass(frozen=_A						)
class 	lowerCamelCase_    ( _A						):






						'''simple docstring'''
						# `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
						a__   =  field(default="question-answering-extractive"						,metadata={"include_in_asdict_even_if_is_default": True}						)
						a__   =  Features({"question": Value("string"						), "context": Value("string"						)}						)
						a__   =  Features(
						    {
						        "answers": Sequence(
						            {
						                "text": Value("string"						),
						                "answer_start": Value("int32"						),
						            }						)
						    }						)
						a__   =  "question"
						a__   =  "context"
						a__   =  "answers"







						@property
						def 			SCREAMING_SNAKE_CASE__		(	self      :			Union[str, Any] )      ->				Dict[str, str]:
									return {self.question_column: "question", self.context_column: "context", self.answers_column: "answers"}