






"""simple docstring"""




import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
     import jax
     import jax.numpy as jnp

     from transformers.modeling_flax_pytorch_utils import (
         convert_pytorch_state_dict_to_flax,
         load_flax_weights_in_pytorch_model,
     )
     from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
     import torch




class  lowercase_     :






      def __init__(     self  ,  a_  ,  a_=1_4  ,  a_=7  ,  a_=True  ,  a_=True  ,  a_=False  ,  a_=True  ,  a_=9_9  ,  a_=3_2  ,  a_=5  ,  a_=4  ,  a_=3_7  ,  a_="gelu"  ,  a_=0.1  ,  a_=0.1  ,  a_=5_1_2  ,  a_=0.02  ,  )						->Dict:







        '''simple docstring'''


        _a					      =						parent
        _a					      =						batch_size
        _a					      =						seq_length
        _a					      =						is_training
        _a					      =						use_input_mask
        _a					      =						use_token_type_ids
        _a					      =						use_labels
        _a					      =						vocab_size
        _a					      =						hidden_size
        _a					      =						num_hidden_layers
        _a					      =						num_attention_heads
        _a					      =						intermediate_size
        _a					      =						hidden_act
        _a					      =						hidden_dropout_prob
        _a					      =						attention_probs_dropout_prob
        _a					      =						max_position_embeddings
        _a					      =						initializer_range
        _a					      =						None
        _a					      =						vocab_size - 1
        _a					      =						vocab_size - 1
        _a					      =						vocab_size - 1






      def       lowerCamelCase__     (     self						)						->List[Any]:







        '''simple docstring'''


        _a					      =						ids_tensor([self.batch_size, self.seq_length]  ,  self.vocab_size						)

        _a					      =						None
        if self.use_input_mask:
          _a					      =						random_attention_mask([self.batch_size, self.seq_length]						)

        _a					      =						GPTaConfig(
            vocab_size=self.vocab_size  ,  n_embd=self.hidden_size  ,  n_layer=self.num_hidden_layers  ,  n_head=self.num_attention_heads  ,  n_positions=self.max_position_embeddings  ,  use_cache=a_  ,  bos_token_id=self.bos_token_id  ,  eos_token_id=self.eos_token_id  ,  pad_token_id=self.pad_token_id  ,  )

        return (config, input_ids, input_mask)






      def       lowerCamelCase__     (     self						)						->str:







        '''simple docstring'''


        _a					      =						self.prepare_config_and_inputs()
        _a      ,						_a      ,						_a					      =						config_and_inputs
        _a					      =						{"input_ids": input_ids, "attention_mask": attention_mask}
        return config, inputs_dict






      def       lowerCamelCase__     (     self						)						->Dict:







        '''simple docstring'''


        _a      ,						_a      ,						_a					      =						self.prepare_config_and_inputs()

        _a					      =						floats_tensor([self.batch_size, self.seq_length, self.hidden_size]						)
        _a					      =						ids_tensor([self.batch_size, self.seq_length]  ,  vocab_size=2						)

        return (
            config,
            input_ids,
            attention_mask,
            encoder_hidden_states,
            encoder_attention_mask,
        )






      def       lowerCamelCase__     (     self  ,  a_  ,  a_  ,  a_  ,  a_						)						->Tuple:







        '''simple docstring'''


        _a					      =						2_0
        _a					      =						model_class_name(a_						)

        _a					      =						model.init_cache(input_ids.shape[0]  ,  a_						)
        _a					      =						jnp.ones((input_ids.shape[0], max_decoder_length)  ,  dtype="i4"						)

        _a					      =						jnp.broadcast_to(
            jnp.arange(input_ids.shape[-1] - 1						)[None, :]  ,  (input_ids.shape[0], input_ids.shape[-1] - 1)						)
        _a					      =						model(
            input_ids[:, :-1]  ,  attention_mask=a_  ,  past_key_values=a_  ,  position_ids=a_  ,  )

        _a					      =						jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]  ,  dtype="i4"						)
        _a					      =						model(
            input_ids[:, -1:]  ,  attention_mask=a_  ,  past_key_values=outputs_cache.past_key_values  ,  position_ids=a_  ,  )

        _a					      =						model(a_						)

        _a					      =						np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])						)						)
        self.parent.assertTrue(diff < 1E-3  ,  msg=f'''Max diff is {diff}'''						)






      def       lowerCamelCase__     (     self  ,  a_  ,  a_  ,  a_  ,  a_						)						->Any:







        '''simple docstring'''


        _a					      =						2_0
        _a					      =						model_class_name(a_						)

        _a					      =						jnp.concatenate(
            [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])						)]  ,  axis=-1  ,  )

        _a					      =						model.init_cache(input_ids.shape[0]  ,  a_						)
        _a					      =						jnp.broadcast_to(
            jnp.arange(input_ids.shape[-1] - 1						)[None, :]  ,  (input_ids.shape[0], input_ids.shape[-1] - 1)						)

        _a					      =						model(
            input_ids[:, :-1]  ,  attention_mask=a_  ,  past_key_values=a_  ,  position_ids=a_  ,  )
        _a					      =						jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]  ,  dtype="i4"						)
        _a					      =						model(
            input_ids[:, -1:]  ,  past_key_values=outputs_cache.past_key_values  ,  attention_mask=a_  ,  position_ids=a_  ,  )

        _a					      =						model(a_  ,  attention_mask=a_						)

        _a					      =						np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])						)						)
        self.parent.assertTrue(diff < 1E-3  ,  msg=f'''Max diff is {diff}'''						)







@require_flax
class  lowercase_     (_UpperCAmelCase,     _UpperCAmelCase,     unittest.TestCase  ):
      A__						:		Optional[int]							      =					(FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
      A__						:		Optional[Any]							      =					(FlaxGPTaLMHeadModel,) if is_flax_available() else ()






      def       lowerCamelCase__     (     self						)						->Tuple:







        '''simple docstring'''


        _a					      =						FlaxGPTaModelTester(self						)






      def       lowerCamelCase__     (     self						)						->Tuple:







        '''simple docstring'''


        for model_class_name in self.all_model_classes:
          _a      ,						_a      ,						_a					      =						self.model_tester.prepare_config_and_inputs()
          self.model_tester.check_use_cache_forward(a_  ,  a_  ,  a_  ,  a_						)






      def       lowerCamelCase__     (     self						)						->Any:







        '''simple docstring'''


        for model_class_name in self.all_model_classes:
          _a      ,						_a      ,						_a					      =						self.model_tester.prepare_config_and_inputs()
          self.model_tester.check_use_cache_forward_with_attn_mask(
              a_  ,  a_  ,  a_  ,  a_						)






      @slow
      def       lowerCamelCase__     (     self						)						->Optional[Any]:







        '''simple docstring'''


        _a					      =						GPTaTokenizer.from_pretrained("gpt2"  ,  pad_token="</s>"  ,  padding_side="left"						)
        _a					      =						tokenizer(["Hello this is a long string", "Hey"]  ,  return_tensors="np"  ,  padding=a_  ,  truncation=a_						)

        _a					      =						FlaxGPTaLMHeadModel.from_pretrained("gpt2"						)
        _a					      =						False
        _a					      =						model.config.eos_token_id

        _a					      =						jax.jit(model.generate						)

        _a					      =						jit_generate(inputs["input_ids"]  ,  attention_mask=inputs["attention_mask"]						).sequences

        _a					      =						tokenizer.batch_decode(a_  ,  skip_special_tokens=a_						)

        _a					      =						[
            "Hello this is a long string of words. I'm going to start with the first one.\n",
            "Hey, I'm not sure if I'm going to be able to do",
        ]

        self.assertListEqual(a_  ,  a_						)






      @is_pt_flax_cross_test
      def       lowerCamelCase__     (     self						)						->int:







        '''simple docstring'''


        _a      ,						_a					      =						self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
          with self.subTest(model_class.__name__						):
            # prepare inputs
            _a					      =						self._prepare_for_class(a_  ,  a_						)
            _a					      =						{k: torch.tensor(v.tolist()						) for k, v in prepared_inputs_dict.items()}

            # load corresponding PyTorch class
            _a					      =						model_class.__name__[4:]  # Skip the "Flax" at the beginning
            _a					      =						getattr(a_  ,  a_						)

            _a      ,						_a					      =						pt_inputs["input_ids"].shape
            _a					      =						np.random.randint(0  ,  seq_length - 1  ,  size=(batch_size,)						)
            for batch_idx, start_index in enumerate(a_						):
              _a					      =						0
              _a					      =						1
              _a					      =						0
              _a					      =						1
            _a					      =						pt_model_class(a_						).eval()
            _a					      =						model_class(a_  ,  dtype=jnp.floataa						)

            _a					      =						convert_pytorch_state_dict_to_flax(pt_model.state_dict()  ,  a_						)
            _a					      =						fx_state

            with torch.no_grad():
              _a					      =						pt_model(**a_						).to_tuple()

            _a					      =						fx_model(**a_						).to_tuple()
            self.assertEqual(len(a_						)  ,  len(a_						)  ,  "Output lengths differ between Flax and PyTorch"						)
            for fx_output, pt_output in zip(a_  ,  a_						):
              self.assert_almost_equals(fx_output[:, -1]  ,  pt_output[:, -1].numpy()  ,  4E-2						)

            with tempfile.TemporaryDirectory() as tmpdirname:
              pt_model.save_pretrained(a_						)
              _a					      =						model_class.from_pretrained(a_  ,  from_pt=a_						)

            _a					      =						fx_model_loaded(**a_						).to_tuple()
            self.assertEqual(
                len(a_						)  ,  len(a_						)  ,  "Output lengths differ between Flax and PyTorch"						)
            for fx_output_loaded, pt_output in zip(a_  ,  a_						):
              self.assert_almost_equals(fx_output_loaded[:, -1]  ,  pt_output[:, -1].numpy()  ,  4E-2						)






      @is_pt_flax_cross_test
      def       lowerCamelCase__     (     self						)						->Union[str, Any]:







        '''simple docstring'''


        _a      ,						_a					      =						self.model_tester.prepare_config_and_inputs_for_common()
        for model_class in self.all_model_classes:
          with self.subTest(model_class.__name__						):
            # prepare inputs
            _a					      =						self._prepare_for_class(a_  ,  a_						)
            _a					      =						{k: torch.tensor(v.tolist()						) for k, v in prepared_inputs_dict.items()}

            # load corresponding PyTorch class
            _a					      =						model_class.__name__[4:]  # Skip the "Flax" at the beginning
            _a					      =						getattr(a_  ,  a_						)

            _a					      =						pt_model_class(a_						).eval()
            _a					      =						model_class(a_  ,  dtype=jnp.floataa						)

            _a					      =						load_flax_weights_in_pytorch_model(a_  ,  fx_model.params						)
            _a      ,						_a					      =						pt_inputs["input_ids"].shape
            _a					      =						np.random.randint(0  ,  seq_length - 1  ,  size=(batch_size,)						)
            for batch_idx, start_index in enumerate(a_						):
              _a					      =						0
              _a					      =						1
              _a					      =						0
              _a					      =						1

            # make sure weights are tied in PyTorch
            pt_model.tie_weights()

            with torch.no_grad():
              _a					      =						pt_model(**a_						).to_tuple()

            _a					      =						fx_model(**a_						).to_tuple()
            self.assertEqual(len(a_						)  ,  len(a_						)  ,  "Output lengths differ between Flax and PyTorch"						)
            for fx_output, pt_output in zip(a_  ,  a_						):
              self.assert_almost_equals(fx_output[:, -1]  ,  pt_output[:, -1].numpy()  ,  4E-2						)

            with tempfile.TemporaryDirectory() as tmpdirname:
              fx_model.save_pretrained(a_						)
              _a					      =						pt_model_class.from_pretrained(a_  ,  from_flax=a_						)

            with torch.no_grad():
              _a					      =						pt_model_loaded(**a_						).to_tuple()

            self.assertEqual(
                len(a_						)  ,  len(a_						)  ,  "Output lengths differ between Flax and PyTorch"						)
            for fx_output, pt_output in zip(a_  ,  a_						):
              self.assert_almost_equals(fx_output[:, -1]  ,  pt_output[:, -1].numpy()  ,  4E-2						)






      @slow
      def       lowerCamelCase__     (     self						)						->int:







        '''simple docstring'''


        for model_class_name in self.all_model_classes:
          _a					      =						model_class_name.from_pretrained("gpt2"  ,  from_pt=a_						)
          _a					      =						model(np.ones((1, 1)						)						)
          self.assertIsNotNone(a_						)










"""simple docstring"""




import inspect
import unittest

from transformers import SwinaSRConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch
     from torch import nn

     from transformers import SwinaSRForImageSuperResolution, SwinaSRModel
     from transformers.models.swinasr.modeling_swinasr import SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
     from PIL import Image

     from transformers import SwinaSRImageProcessor




class  lowercase_     :






      def __init__(     self  ,  a_  ,  a_=1_3  ,  a_=3_2  ,  a_=1  ,  a_=3  ,  a_=1_6  ,  a_=[1, 2, 1]  ,  a_=[2, 2, 4]  ,  a_=2  ,  a_=2.0  ,  a_=True  ,  a_=0.0  ,  a_=0.0  ,  a_=0.1  ,  a_="gelu"  ,  a_=False  ,  a_=True  ,  a_=0.02  ,  a_=1E-5  ,  a_=True  ,  a_=None  ,  a_=False  ,  a_=2  ,  )						->str:







        '''simple docstring'''


        _a					      =						parent
        _a					      =						batch_size
        _a					      =						image_size
        _a					      =						patch_size
        _a					      =						num_channels
        _a					      =						embed_dim
        _a					      =						depths
        _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					      =						patch_norm
        _a					      =						layer_norm_eps
        _a					      =						initializer_range
        _a					      =						is_training
        _a					      =						scope
        _a					      =						use_labels
        _a					      =						upscale

        # here we set some attributes to make tests pass
        _a					      =						len(a_						)
        _a					      =						embed_dim
        _a					      =						(image_size // patch_size) ** 2






      def       lowerCamelCase__     (     self						)						->Any:







        '''simple docstring'''


        _a					      =						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

        _a					      =						None
        if self.use_labels:
          _a					      =						ids_tensor([self.batch_size]  ,  self.type_sequence_label_size						)

        _a					      =						self.get_config()

        return config, pixel_values, labels






      def       lowerCamelCase__     (     self						)						->Union[str, Any]:







        '''simple docstring'''


        return SwinaSRConfig(
            image_size=self.image_size  ,  patch_size=self.patch_size  ,  num_channels=self.num_channels  ,  embed_dim=self.embed_dim  ,  depths=self.depths  ,  num_heads=self.num_heads  ,  window_size=self.window_size  ,  mlp_ratio=self.mlp_ratio  ,  qkv_bias=self.qkv_bias  ,  hidden_dropout_prob=self.hidden_dropout_prob  ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,  drop_path_rate=self.drop_path_rate  ,  hidden_act=self.hidden_act  ,  use_absolute_embeddings=self.use_absolute_embeddings  ,  path_norm=self.patch_norm  ,  layer_norm_eps=self.layer_norm_eps  ,  initializer_range=self.initializer_range  ,  upscale=self.upscale  ,  )






      def       lowerCamelCase__     (     self  ,  a_  ,  a_  ,  a_						)						->Union[str, Any]:







        '''simple docstring'''


        _a					      =						SwinaSRModel(config=a_						)
        model.to(a_						)
        model.eval()
        _a					      =						model(a_						)

        self.parent.assertEqual(
            result.last_hidden_state.shape  ,  (self.batch_size, self.embed_dim, self.image_size, self.image_size)						)






      def       lowerCamelCase__     (     self  ,  a_  ,  a_  ,  a_						)						->Optional[int]:







        '''simple docstring'''


        _a					      =						SwinaSRForImageSuperResolution(a_						)
        model.to(a_						)
        model.eval()
        _a					      =						model(a_						)

        _a					      =						self.image_size * self.upscale
        self.parent.assertEqual(
            result.reconstruction.shape  ,  (self.batch_size, self.num_channels, expected_image_size, expected_image_size)						)






      def       lowerCamelCase__     (     self						)						->Tuple:







        '''simple docstring'''


        _a					      =						self.prepare_config_and_inputs()
        _a      ,						_a      ,						_a					      =						config_and_inputs
        _a					      =						{"pixel_values": pixel_values}
        return config, inputs_dict







@require_torch
class  lowercase_     (_UpperCAmelCase,     _UpperCAmelCase,     unittest.TestCase  ):
      A__						:		str							      =					(SwinaSRModel, SwinaSRForImageSuperResolution) if is_torch_available() else ()
      A__						:		Optional[Any]							      =					{'''feature-extraction''': SwinaSRModel} if is_torch_available() else {}

      A__						:		List[str]							      =					False
      A__						:		Optional[Any]							      =					False
      A__						:		str							      =					False
      A__						:		Optional[int]							      =					False
      A__						:		List[Any]							      =					False






      def       lowerCamelCase__     (     self						)						->Union[str, Any]:







        '''simple docstring'''


        _a					      =						SwinaSRModelTester(self						)
        _a					      =						ConfigTester(self  ,  config_class=a_  ,  embed_dim=3_7						)






      def       lowerCamelCase__     (     self						)						->Union[str, Any]:







        '''simple docstring'''


        self.config_tester.create_and_test_config_to_json_string()
        self.config_tester.create_and_test_config_to_json_file()
        self.config_tester.create_and_test_config_from_and_save_pretrained()
        self.config_tester.create_and_test_config_with_num_labels()
        self.config_tester.check_config_can_be_init_without_params()
        self.config_tester.check_config_arguments_init()






      def       lowerCamelCase__     (     self						)						->int:







        '''simple docstring'''


        _a					      =						self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*a_						)






      def       lowerCamelCase__     (     self						)						->Optional[int]:







        '''simple docstring'''


        _a					      =						self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_image_super_resolution(*a_						)






      @unittest.skip(reason="Got `CUDA error: misaligned address` with PyTorch 2.0.0."						)
      def       lowerCamelCase__     (     self						)						->int:







        '''simple docstring'''


        pass






      @unittest.skip(reason="Swin2SR does not use inputs_embeds"						)
      def       lowerCamelCase__     (     self						)						->Union[str, Any]:







        '''simple docstring'''


        pass






      @unittest.skip(reason="Swin2SR does not support training yet"						)
      def       lowerCamelCase__     (     self						)						->Union[str, Any]:







        '''simple docstring'''


        pass






      @unittest.skip(reason="Swin2SR does not support training yet"						)
      def       lowerCamelCase__     (     self						)						->Any:







        '''simple docstring'''


        pass






      def       lowerCamelCase__     (     self						)						->Tuple:







        '''simple docstring'''


        _a      ,						_a					      =						self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
          _a					      =						model_class(a_						)
          self.assertIsInstance(model.get_input_embeddings()  ,  (nn.Module)						)
          _a					      =						model.get_output_embeddings()
          self.assertTrue(x is None or isinstance(a_  ,  nn.Linear						)						)






      def       lowerCamelCase__     (     self						)						->Optional[Any]:







        '''simple docstring'''


        _a      ,						_a					      =						self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
          _a					      =						model_class(a_						)
          _a					      =						inspect.signature(model.forward						)
          # signature.parameters is an OrderedDict => so arg_names order is deterministic
          _a					      =						[*signature.parameters.keys()]

          _a					      =						["pixel_values"]
          self.assertListEqual(arg_names[:1]  ,  a_						)






      @slow
      def       lowerCamelCase__     (     self						)						->Dict:







        '''simple docstring'''


        for model_name in SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          _a					      =						SwinaSRModel.from_pretrained(a_						)
          self.assertIsNotNone(a_						)






      def       lowerCamelCase__     (     self						)						->Dict:







        '''simple docstring'''


        _a      ,						_a					      =						self.model_tester.prepare_config_and_inputs_for_common()

        _a					      =						_config_zero_init(a_						)
        for model_class in self.all_model_classes:
          _a					      =						model_class(config=a_						)
          for name, param in model.named_parameters():
            if "logit_scale" in name:
              continue
            if param.requires_grad:
              self.assertIn(
                  ((param.data.mean() * 1E9).round() / 1E9).item()  ,  [0.0, 1.0]  ,  msg=f'''Parameter {name} of model {model_class} seems not properly initialized'''  ,  )






      def       lowerCamelCase__     (     self						)						->Tuple:







        '''simple docstring'''


        _a      ,						_a					      =						self.model_tester.prepare_config_and_inputs_for_common()
        _a					      =						True

        for model_class in self.all_model_classes:
          _a					      =						True
          _a					      =						False
          _a					      =						True
          _a					      =						model_class(a_						)
          model.to(a_						)
          model.eval()
          with torch.no_grad():
            _a					      =						model(**self._prepare_for_class(a_  ,  a_						)						)
          _a					      =						outputs.attentions
          _a					      =						len(self.model_tester.depths						)
          self.assertEqual(len(a_						)  ,  a_						)

          # check that output_attentions also work using config
          del inputs_dict["output_attentions"]
          _a					      =						True
          _a					      =						config.window_size**2
          _a					      =						model_class(a_						)
          model.to(a_						)
          model.eval()
          with torch.no_grad():
            _a					      =						model(**self._prepare_for_class(a_  ,  a_						)						)
          _a					      =						outputs.attentions
          self.assertEqual(len(a_						)  ,  a_						)

          self.assertListEqual(
              list(attentions[0].shape[-3:]						)  ,  [self.model_tester.num_heads[0], window_size_squared, window_size_squared]  ,  )
          _a					      =						len(a_						)

          # Check attention is always last and order is fine
          _a					      =						True
          _a					      =						True
          _a					      =						model_class(a_						)
          model.to(a_						)
          model.eval()
          with torch.no_grad():
            _a					      =						model(**self._prepare_for_class(a_  ,  a_						)						)

          self.assertEqual(out_len + 1  ,  len(a_						)						)

          _a					      =						outputs.attentions

          self.assertEqual(len(a_						)  ,  a_						)

          self.assertListEqual(
              list(self_attentions[0].shape[-3:]						)  ,  [self.model_tester.num_heads[0], window_size_squared, window_size_squared]  ,  )







@require_vision
@require_torch
@slow
class  lowercase_     (unittest.TestCase  ):






      def       lowerCamelCase__     (     self						)						->Optional[Any]:







        '''simple docstring'''


        _a					      =						SwinaSRImageProcessor()
        _a					      =						SwinaSRForImageSuperResolution.from_pretrained("caidas/swin2SR-classical-sr-x2-64"						).to(a_						)

        _a					      =						Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						)
        _a					      =						processor(images=a_  ,  return_tensors="pt"						).to(a_						)

        # forward pass
        with torch.no_grad():
          _a					      =						model(**a_						)

        # verify the logits
        _a					      =						torch.Size([1, 3, 9_7_6, 1_2_9_6]						)
        self.assertEqual(outputs.reconstruction.shape  ,  a_						)
        _a					      =						torch.tensor(
            [[0.5_458, 0.5_546, 0.5_638], [0.5_526, 0.5_565, 0.5_651], [0.5_396, 0.5_426, 0.5_621]]						).to(a_						)
        self.assertTrue(torch.allclose(outputs.reconstruction[0, 0, :3, :3]  ,  a_  ,  atol=1E-4						)						)


