


from dataclasses import dataclass
from typing import Optional, Tuple

import torch
from torch import nn
from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel
from transformers.utils import ModelOutput
@dataclass
class 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[torch.FloatTensor]     		=		None
   __A :      torch.FloatTensor     		=		None
   __A :      Optional[Tuple[torch.FloatTensor]]     		=		None
   __A :      Optional[Tuple[torch.FloatTensor]]     		=		None



class 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   def __init__(		self						,				__A=1						,				__A=0						,				__A=2						,				__A=512						,				__A="cls"						,				__A=False						,				__A=True						,				**__A						,				):






     """simple docstring"""





     super().__init__(pad_token_id=__A						,				bos_token_id=__A						,				eos_token_id=__A						,				**__A )
     lowerCamelCase :					Tuple    =				project_dim
     lowerCamelCase :					List[Any]    =				pooler_fn
     lowerCamelCase :					Any    =				learn_encoder
     lowerCamelCase :					List[str]    =				use_attention_mask



class 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      str     		=		[R"pooler", R"logit_scale"]
   __A :      str     		=		[R"position_ids", R"predictions.decoder.bias"]
   __A :      str     		=		"roberta"
   __A :      int     		=		RobertaSeriesConfig






   def __init__(		self						,				__A ):






     """simple docstring"""





     super().__init__(__A )
     lowerCamelCase :					Dict    =				XLMRobertaModel(__A )
     lowerCamelCase :					Union[str, Any]    =				nn.Linear(config.hidden_size						,				config.project_dim )
     lowerCamelCase :					Optional[int]    =				getattr(__A						,				"has_pre_transformation"						,				__A )
     if self.has_pre_transformation:
       lowerCamelCase :					List[Any]    =				nn.Linear(config.hidden_size						,				config.project_dim )
       lowerCamelCase :					Tuple    =				nn.LayerNorm(config.hidden_size						,				eps=config.layer_norm_eps )
     self.post_init()






   def _snake_case    (		self						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				__A = None						,				):






     """simple docstring"""





     lowerCamelCase :					List[str]    =				return_dict if return_dict is not None else self.config.use_return_dict

     lowerCamelCase :					Tuple    =				self.base_model(
         input_ids=__A						,				attention_mask=__A						,				token_type_ids=__A						,				position_ids=__A						,				head_mask=__A						,				inputs_embeds=__A						,				encoder_hidden_states=__A						,				encoder_attention_mask=__A						,				output_attentions=__A						,				output_hidden_states=True if self.has_pre_transformation else output_hidden_states						,				return_dict=__A						,				)

     if self.has_pre_transformation:
       lowerCamelCase :					str    =				outputs["hidden_states"][-2]
       lowerCamelCase :					Tuple    =				self.pre_LN(__A )
       lowerCamelCase :					Dict    =				self.transformation_pre(__A )

       return TransformationModelOutput(
           projection_state=__A						,				last_hidden_state=outputs.last_hidden_state						,				hidden_states=outputs.hidden_states						,				attentions=outputs.attentions						,				)
     else:
       lowerCamelCase :					Optional[int]    =				self.transformation(outputs.last_hidden_state )
       return TransformationModelOutput(
           projection_state=__A						,				last_hidden_state=outputs.last_hidden_state						,				hidden_states=outputs.hidden_states						,				attentions=outputs.attentions						,				)







from ..utils import DummyObject, requires_backends
class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Any     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[int]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      str     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      List[Any]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[int]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Dict     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Dict     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Union[str, Any]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[int]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[Any]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Any     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[Any]     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



class 	UpperCAmelCase_					(					metaclass=UpperCamelCase    ):

   '''simple docstring'''




   __A :      int     		=		["flax"]






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






     """simple docstring"""





     requires_backends(self						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )






   @classmethod
   def _snake_case    (		cls						,				*__A						,				**__A ):






     """simple docstring"""





     requires_backends(cls						,				["flax"] )



