






from typing import Dict

from .base import GenericTensor, Pipeline



class 							_UpperCamelCase			(a_			):


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						**__UpperCamelCase	)->	Union[str, Any]:
           if tokenize_kwargs is None:
                __lowerCAmelCase								=					{}

           if truncation is not None:
                if "truncation" in tokenize_kwargs:
                     raise ValueError(
                         "truncation parameter defined twice (given as keyword argument as well as in tokenize_kwargs)"	)
                __lowerCAmelCase								=					truncation

           __lowerCAmelCase								=					tokenize_kwargs

           __lowerCAmelCase								=					{}
           if return_tensors is not None:
                __lowerCAmelCase								=					return_tensors

           return preprocess_params, {}, postprocess_params


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase					,						**__UpperCamelCase	)->	Dict[str, GenericTensor]:
           __lowerCAmelCase								=					self.framework
           __lowerCAmelCase								=					self.tokenizer(__UpperCamelCase					,						return_tensors=__UpperCamelCase					,						**__UpperCamelCase	)
           return model_inputs


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase	)->	Tuple:
           __lowerCAmelCase								=					self.model(**__UpperCamelCase	)
           return model_outputs


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase					,						__UpperCamelCase=False	)->	Optional[int]:
           # [0] is the first available tensor, logits or last_hidden_state.
           if return_tensors:
                return model_outputs[0]
           if self.framework == "pt":
                return model_outputs[0].tolist()
           elif self.framework == "tf":
                return model_outputs[0].numpy().tolist()


      def __call__(	self					,						*__UpperCamelCase					,						**__UpperCamelCase	)->	List[Any]:
           return super().__call__(*__UpperCamelCase					,						**__UpperCamelCase	)














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


lowerCamelCase			:					int         =	logging.get_logger(__name__)

lowerCamelCase			:					Tuple         =	{
    '''caidas/swin2sr-classicalsr-x2-64''': (
        '''https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json'''
    ),
}



class 							_UpperCamelCase			(a_			):
      snake_case_  =							"""swin2sr"""

      snake_case_  =							{
          """hidden_size""": """embed_dim""",
          """num_attention_heads""": """num_heads""",
          """num_hidden_layers""": """num_layers""",
      }


      def __init__(	self					,						__UpperCamelCase=6_4					,						__UpperCamelCase=1					,						__UpperCamelCase=3					,						__UpperCamelCase=1_8_0					,						__UpperCamelCase=[6, 6, 6, 6, 6, 6]					,						__UpperCamelCase=[6, 6, 6, 6, 6, 6]					,						__UpperCamelCase=8					,						__UpperCamelCase=2.0					,						__UpperCamelCase=True					,						__UpperCamelCase=0.0					,						__UpperCamelCase=0.0					,						__UpperCamelCase=0.1					,						__UpperCamelCase="gelu"					,						__UpperCamelCase=False					,						__UpperCamelCase=0.0_2					,						__UpperCamelCase=1e-5					,						__UpperCamelCase=2					,						__UpperCamelCase=1.0					,						__UpperCamelCase="1conv"					,						__UpperCamelCase="pixelshuffle"					,						**__UpperCamelCase					,						)->	Tuple:
           super().__init__(**__UpperCamelCase	)

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






