






"""simple docstring"""







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        _SCREAMING_SNAKE_CASE						(  _UpperCamelCase							):





							"""simple docstring"""





							_SCREAMING_SNAKE_CASE    =None
							_SCREAMING_SNAKE_CASE    =None
							_SCREAMING_SNAKE_CASE    =None
							_SCREAMING_SNAKE_CASE    =None







class        _SCREAMING_SNAKE_CASE						(  _UpperCamelCase							):





							"""simple docstring"""





							def __init__(   self:     List[Any]				,		__A:     Tuple=1				,		__A:     int=0				,		__A:     List[Any]=2				,		__A:     Tuple=512				,		__A:     List[str]="cls"				,		__A:     List[str]=False				,		__A:     Union[str, Any]=True				,		**__A:     List[Any]				,		):

												'''simple docstring'''

												super().__init__(pad_token_id=_UpperCAmelCase				,		bos_token_id=_UpperCAmelCase				,		eos_token_id=_UpperCAmelCase				,		**_UpperCAmelCase    )
												a__          =  project_dim
												a__          =  pooler_fn
												a__          =  learn_encoder
												a__          =  use_attention_mask







class        _SCREAMING_SNAKE_CASE						(  _UpperCamelCase							):





							"""simple docstring"""





							_SCREAMING_SNAKE_CASE    =[r'pooler', r'logit_scale']
							_SCREAMING_SNAKE_CASE    =[r'position_ids', r'predictions.decoder.bias']
							_SCREAMING_SNAKE_CASE    ='roberta'
							_SCREAMING_SNAKE_CASE    =RobertaSeriesConfig




							def __init__(   self:     str				,		__A:     Union[str, Any]    ):

												'''simple docstring'''

												super().__init__(_UpperCAmelCase    )
												a__          =  XLMRobertaModel(_UpperCAmelCase    )
												a__          =  nn.Linear(config.hidden_size				,		config.project_dim    )
												a__          =  getattr(_UpperCAmelCase				,		'''has_pre_transformation'''				,		_UpperCAmelCase    )
												if self.has_pre_transformation:
																	a__          =  nn.Linear(config.hidden_size				,		config.project_dim    )
																	a__          =  nn.LayerNorm(config.hidden_size				,		eps=config.layer_norm_eps    )
												self.post_init()





							def  lowercase		(   self:     Union[str, Any]				,		__A:     Union[str, Any] = None				,		__A:     List[Any] = None				,		__A:     Tuple = None				,		__A:     int = None				,		__A:     Dict = None				,		__A:     Dict = None				,		__A:     str = None				,		__A:     Optional[int] = None				,		__A:     Union[str, Any] = None				,		__A:     Any = None				,		__A:     Dict = None				,		):

												'''simple docstring'''

												a__          =  return_dict if return_dict is not None else self.config.use_return_dict

												a__          =  self.base_model(
												    input_ids=_UpperCAmelCase				,		attention_mask=_UpperCAmelCase				,		token_type_ids=_UpperCAmelCase				,		position_ids=_UpperCAmelCase				,		head_mask=_UpperCAmelCase				,		inputs_embeds=_UpperCAmelCase				,		encoder_hidden_states=_UpperCAmelCase				,		encoder_attention_mask=_UpperCAmelCase				,		output_attentions=_UpperCAmelCase				,		output_hidden_states=True if self.has_pre_transformation else output_hidden_states				,		return_dict=_UpperCAmelCase				,		)

												if self.has_pre_transformation:
																	a__          =  outputs['''hidden_states'''][-2]
																	a__          =  self.pre_LN(_UpperCAmelCase    )
																	a__          =  self.transformation_pre(_UpperCAmelCase    )

																	return TransformationModelOutput(
																	    projection_state=_UpperCAmelCase				,		last_hidden_state=outputs.last_hidden_state				,		hidden_states=outputs.hidden_states				,		attentions=outputs.attentions				,		)
												else:
																	a__          =  self.transformation(outputs.last_hidden_state    )
																	return TransformationModelOutput(
																	    projection_state=_UpperCAmelCase				,		last_hidden_state=outputs.last_hidden_state				,		hidden_states=outputs.hidden_states				,		attentions=outputs.attentions				,		)










"""simple docstring"""







from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a       :	Any             = logging.get_logger(__name__)

__a       :	Union[str, Any]             = {
    'caidas/swin2sr-classicalsr-x2-64': (
        'https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json'
    ),
}







class        _SCREAMING_SNAKE_CASE						(  __snake_case							):





							"""simple docstring"""





							_SCREAMING_SNAKE_CASE    ='swin2sr'

							_SCREAMING_SNAKE_CASE    ={
							    'hidden_size': 'embed_dim',
							    'num_attention_heads': 'num_heads',
							    'num_hidden_layers': 'num_layers',
							}




							def __init__(   self:     Union[str, Any]				,		__A:     List[Any]=64				,		__A:     int=1				,		__A:     Dict=3				,		__A:     List[Any]=180				,		__A:     int=[6, 6, 6, 6, 6, 6]				,		__A:     Tuple=[6, 6, 6, 6, 6, 6]				,		__A:     int=8				,		__A:     Optional[int]=2.0				,		__A:     Optional[int]=True				,		__A:     int=0.0				,		__A:     Any=0.0				,		__A:     Optional[Any]=0.1				,		__A:     Optional[Any]="gelu"				,		__A:     Dict=False				,		__A:     List[Any]=0.0_2				,		__A:     List[Any]=1e-5				,		__A:     List[str]=2				,		__A:     int=1.0				,		__A:     Dict="1conv"				,		__A:     Optional[Any]="pixelshuffle"				,		**__A:     Dict				,		):

												'''simple docstring'''

												super().__init__(**__A    )

												a__          =  image_size
												a__          =  patch_size
												a__          =  num_channels
												a__          =  embed_dim
												a__          =  depths
												a__          =  len(__A    )
												a__          =  num_heads
												a__          =  window_size
												a__          =  mlp_ratio
												a__          =  qkv_bias
												a__          =  hidden_dropout_prob
												a__          =  attention_probs_dropout_prob
												a__          =  drop_path_rate
												a__          =  hidden_act
												a__          =  use_absolute_embeddings
												a__          =  layer_norm_eps
												a__          =  initializer_range
												a__          =  upscale
												a__          =  img_range
												a__          =  resi_connection
												a__          =  upsampler


