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   A							:


   def __init__(self  :		int ,						__UpperCAmelCase  :		Optional[Any] ,						__UpperCAmelCase  :		Tuple=1_3 ,						__UpperCAmelCase  :		Any=3_2 ,						__UpperCAmelCase  :		str=1 ,						__UpperCAmelCase  :		Optional[int]=3 ,						__UpperCAmelCase  :		Tuple=1_6 ,						__UpperCAmelCase  :		List[Any]=[1, 2, 1] ,						__UpperCAmelCase  :		Optional[int]=[2, 2, 4] ,						__UpperCAmelCase  :		Tuple=2 ,						__UpperCAmelCase  :		Optional[int]=2.0 ,						__UpperCAmelCase  :		Dict=True ,						__UpperCAmelCase  :		List[Any]=0.0 ,						__UpperCAmelCase  :		List[Any]=0.0 ,						__UpperCAmelCase  :		str=0.1 ,						__UpperCAmelCase  :		str="gelu" ,						__UpperCAmelCase  :		List[Any]=False ,						__UpperCAmelCase  :		Dict=True ,						__UpperCAmelCase  :		Union[str, Any]=0.02 ,						__UpperCAmelCase  :		List[str]=1E-5 ,						__UpperCAmelCase  :		str=True ,						__UpperCAmelCase  :		str=None ,						__UpperCAmelCase  :		Any=False ,						__UpperCAmelCase  :		Optional[int]=2 ,						)		->       Optional[int]:
         """simple docstring"""



         UpperCAmelCase__			=						parent
         UpperCAmelCase__			=						batch_size
         UpperCAmelCase__			=						image_size
         UpperCAmelCase__			=						patch_size
         UpperCAmelCase__			=						num_channels
         UpperCAmelCase__			=						embed_dim
         UpperCAmelCase__			=						depths
         UpperCAmelCase__			=						num_heads
         UpperCAmelCase__			=						window_size
         UpperCAmelCase__			=						mlp_ratio
         UpperCAmelCase__			=						qkv_bias
         UpperCAmelCase__			=						hidden_dropout_prob
         UpperCAmelCase__			=						attention_probs_dropout_prob
         UpperCAmelCase__			=						drop_path_rate
         UpperCAmelCase__			=						hidden_act
         UpperCAmelCase__			=						use_absolute_embeddings
         UpperCAmelCase__			=						patch_norm
         UpperCAmelCase__			=						layer_norm_eps
         UpperCAmelCase__			=						initializer_range
         UpperCAmelCase__			=						is_training
         UpperCAmelCase__			=						scope
         UpperCAmelCase__			=						use_labels
         UpperCAmelCase__			=						upscale

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


   def     lowercase_   (self  :		List[Any]	)		->       Optional[Any]:
         """simple docstring"""



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

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

         UpperCAmelCase__			=						self.get_config()

         return config, pixel_values, labels


   def     lowercase_   (self  :		int	)		->       List[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     lowercase_   (self  :		List[str] ,						__UpperCAmelCase  :		Union[str, Any] ,						__UpperCAmelCase  :		List[Any] ,						__UpperCAmelCase  :		str	)		->       Tuple:
         """simple docstring"""



         UpperCAmelCase__			=						SwinaSRModel(config=__UpperCAmelCase	)
         model.to(__UpperCAmelCase	)
         model.eval()
         UpperCAmelCase__			=						model(__UpperCAmelCase	)

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


   def     lowercase_   (self  :		Union[str, Any] ,						__UpperCAmelCase  :		Any ,						__UpperCAmelCase  :		str ,						__UpperCAmelCase  :		Optional[int]	)		->       Dict:
         """simple docstring"""



         UpperCAmelCase__			=						SwinaSRForImageSuperResolution(__UpperCAmelCase	)
         model.to(__UpperCAmelCase	)
         model.eval()
         UpperCAmelCase__			=						model(__UpperCAmelCase	)

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





   def     lowercase_   (self  :		str	)		->       Any:
         """simple docstring"""



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





@require_torch
class   A							(       UpperCAmelCase_	,       UpperCAmelCase_	,       unittest.TestCase  ):
   __UpperCAmelCase				:				Dict          =    (SwinaSRModel, SwinaSRForImageSuperResolution) if is_torch_available() else ()
   __UpperCAmelCase				:				Optional[Any]          =    {'feature-extraction': SwinaSRModel} if is_torch_available() else {}

   __UpperCAmelCase				:				Dict          =    False
   __UpperCAmelCase				:				Dict          =    False
   __UpperCAmelCase				:				Any          =    False
   __UpperCAmelCase				:				int          =    False
   __UpperCAmelCase				:				List[str]          =    False


   def     lowercase_   (self  :		int	)		->       List[Any]:
         """simple docstring"""



         UpperCAmelCase__			=						SwinaSRModelTester(self	)
         UpperCAmelCase__			=						ConfigTester(self ,						config_class=__UpperCAmelCase ,						embed_dim=3_7	)


   def     lowercase_   (self  :		List[Any]	)		->       str:
         """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     lowercase_   (self  :		Optional[Any]	)		->       List[str]:
         """simple docstring"""



         UpperCAmelCase__			=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*__UpperCAmelCase	)


   def     lowercase_   (self  :		Dict	)		->       List[str]:
         """simple docstring"""



         UpperCAmelCase__			=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_image_super_resolution(*__UpperCAmelCase	)


   @unittest.skip(reason="Got `CUDA error: misaligned address` with PyTorch 2.0.0."	)
   def     lowercase_   (self  :		Tuple	)		->       List[str]:
         """simple docstring"""



         pass


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



         pass


   @unittest.skip(reason="Swin2SR does not support training yet"	)
   def     lowercase_   (self  :		Optional[Any]	)		->       Any:
         """simple docstring"""



         pass


   @unittest.skip(reason="Swin2SR does not support training yet"	)
   def     lowercase_   (self  :		Dict	)		->       List[str]:
         """simple docstring"""



         pass


   def     lowercase_   (self  :		List[Any]	)		->       Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__	,   UpperCAmelCase__			=						self.model_tester.prepare_config_and_inputs_for_common()

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


   def     lowercase_   (self  :		Dict	)		->       Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__	,   UpperCAmelCase__			=						self.model_tester.prepare_config_and_inputs_for_common()

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

               UpperCAmelCase__			=						["pixel_values"]
               self.assertListEqual(arg_names[:1] ,						__UpperCAmelCase	)


   @slow
   def     lowercase_   (self  :		Optional[int]	)		->       Dict:
         """simple docstring"""



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


   def     lowercase_   (self  :		Union[str, Any]	)		->       List[str]:
         """simple docstring"""



         UpperCAmelCase__	,   UpperCAmelCase__			=						self.model_tester.prepare_config_and_inputs_for_common()

         UpperCAmelCase__			=						_config_zero_init(__UpperCAmelCase	)
         for model_class in self.all_model_classes:
               UpperCAmelCase__			=						model_class(config=__UpperCAmelCase	)
               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     lowercase_   (self  :		Union[str, Any]	)		->       List[Any]:
         """simple docstring"""



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

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

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

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

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

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

               UpperCAmelCase__			=						outputs.attentions

               self.assertEqual(len(__UpperCAmelCase	) ,						__UpperCAmelCase	)

               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   A							(       unittest.TestCase  ):


   def     lowercase_   (self  :		Optional[Any]	)		->       Tuple:
         """simple docstring"""



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

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

         # forward pass
         with torch.no_grad():
               UpperCAmelCase__			=						model(**__UpperCAmelCase	)

         # verify the logits
         UpperCAmelCase__			=						torch.Size([1, 3, 9_7_6, 1_2_9_6]	)
         self.assertEqual(outputs.reconstruction.shape ,						__UpperCAmelCase	)
         UpperCAmelCase__			=						torch.tensor(
             [[0.5458, 0.5546, 0.5638], [0.5526, 0.5565, 0.5651], [0.5396, 0.5426, 0.5621]]	).to(__UpperCAmelCase	)
         self.assertTrue(torch.allclose(outputs.reconstruction[0, 0, :3, :3] ,						__UpperCAmelCase ,						atol=1E-4	)	)




import os
import pickle
import unittest
from collections import UserDict, namedtuple

import torch

from accelerate.test_utils.testing import require_cuda, require_torch_min_version
from accelerate.test_utils.training import RegressionModel
from accelerate.utils import (
    convert_outputs_to_fpaa,
    extract_model_from_parallel,
    find_device,
    listify,
    patch_environment,
    recursively_apply,
    send_to_device,
)


UpperCamelCase__       							=      namedtuple('ExampleNamedTuple', 'a b c')





class   A							(       unittest.TestCase  ):


   def     lowercase_   (self  :		str	)		->       List[Any]:
         """simple docstring"""



         UpperCAmelCase__			=						torch.randn(5 ,						2	)
         UpperCAmelCase__			=						torch.device("cuda"	) if torch.cuda.is_available() else torch.device("cpu"	)

         UpperCAmelCase__			=						send_to_device(__UpperCAmelCase ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta.cpu() ,						__UpperCAmelCase	)	)

         UpperCAmelCase__			=						send_to_device((tensor, [tensor, tensor], 1) ,						__UpperCAmelCase	)
         self.assertIsInstance(__UpperCAmelCase ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta[0].cpu() ,						__UpperCAmelCase	)	)
         self.assertIsInstance(resulta[1] ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta[1][0].cpu() ,						__UpperCAmelCase	)	)
         self.assertTrue(torch.equal(resulta[1][1].cpu() ,						__UpperCAmelCase	)	)
         self.assertEqual(resulta[2] ,						1	)

         UpperCAmelCase__			=						send_to_device({"a": tensor, "b": [tensor, tensor], "c": 1} ,						__UpperCAmelCase	)
         self.assertIsInstance(__UpperCAmelCase ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta["a"].cpu() ,						__UpperCAmelCase	)	)
         self.assertIsInstance(resulta["b"] ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta["b"][0].cpu() ,						__UpperCAmelCase	)	)
         self.assertTrue(torch.equal(resulta["b"][1].cpu() ,						__UpperCAmelCase	)	)
         self.assertEqual(resulta["c"] ,						1	)

         UpperCAmelCase__			=						send_to_device(ExampleNamedTuple(a=__UpperCAmelCase ,						b=[tensor, tensor] ,						c=1	) ,						__UpperCAmelCase	)
         self.assertIsInstance(__UpperCAmelCase ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta.a.cpu() ,						__UpperCAmelCase	)	)
         self.assertIsInstance(resulta.b ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta.b[0].cpu() ,						__UpperCAmelCase	)	)
         self.assertTrue(torch.equal(resulta.b[1].cpu() ,						__UpperCAmelCase	)	)
         self.assertEqual(resulta.c ,						1	)

         UpperCAmelCase__			=						send_to_device(UserDict({"a": tensor, "b": [tensor, tensor], "c": 1}	) ,						__UpperCAmelCase	)
         self.assertIsInstance(__UpperCAmelCase ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta["a"].cpu() ,						__UpperCAmelCase	)	)
         self.assertIsInstance(resulta["b"] ,						__UpperCAmelCase	)
         self.assertTrue(torch.equal(resulta["b"][0].cpu() ,						__UpperCAmelCase	)	)
         self.assertTrue(torch.equal(resulta["b"][1].cpu() ,						__UpperCAmelCase	)	)
         self.assertEqual(resulta["c"] ,						1	)


   def     lowercase_   (self  :		int	)		->       int:
         """simple docstring"""



         with self.assertRaises(__UpperCAmelCase	) as cm:
               UpperCAmelCase__			=						recursively_apply(torch.tensor ,						(torch.tensor(1	), 1) ,						error_on_other_type=__UpperCAmelCase	)
         self.assertEqual(
             str(cm.exception	) ,						"Unsupported types (<class 'int'>) passed to `tensor`. Only nested list/tuple/dicts of objects that are valid for `is_torch_tensor` should be passed." ,						)


   def     lowercase_   (self  :		List[str]	)		->       Any:
         """simple docstring"""



         UpperCAmelCase__			=						torch.tensor([1, 2, 3, 4, 5]	)
         self.assertEqual(listify(__UpperCAmelCase	) ,						[1, 2, 3, 4, 5]	)

         UpperCAmelCase__			=						torch.tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 1_0]]	)
         self.assertEqual(listify(__UpperCAmelCase	) ,						[[1, 2, 3, 4, 5], [6, 7, 8, 9, 1_0]]	)

         UpperCAmelCase__			=						torch.tensor([[[1, 2, 3, 4, 5], [6, 7, 8, 9, 1_0]], [[1_1, 1_2, 1_3, 1_4, 1_5], [1_6, 1_7, 1_8, 1_9, 2_0]]]	)
         self.assertEqual(
             listify(__UpperCAmelCase	) ,						[[[1, 2, 3, 4, 5], [6, 7, 8, 9, 1_0]], [[1_1, 1_2, 1_3, 1_4, 1_5], [1_6, 1_7, 1_8, 1_9, 2_0]]]	)


   def     lowercase_   (self  :		Union[str, Any]	)		->       Dict:
         """simple docstring"""



         with patch_environment(aa=1 ,						BB=2	):
               self.assertEqual(os.environ.get("AA"	) ,						"1"	)
               self.assertEqual(os.environ.get("BB"	) ,						"2"	)

         self.assertNotIn("AA" ,						os.environ	)
         self.assertNotIn("BB" ,						os.environ	)


   def     lowercase_   (self  :		int	)		->       str:
         """simple docstring"""



         UpperCAmelCase__			=						RegressionModel()
         UpperCAmelCase__			=						model.forward
         UpperCAmelCase__			=						convert_outputs_to_fpaa(model.forward	)
         UpperCAmelCase__			=						extract_model_from_parallel(__UpperCAmelCase ,						keep_fpaa_wrapper=__UpperCAmelCase	)
         UpperCAmelCase__			=						pickle.dumps(__UpperCAmelCase	)


   @require_cuda
   def     lowercase_   (self  :		List[str]	)		->       Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__			=						RegressionModel()
         UpperCAmelCase__			=						model.forward
         UpperCAmelCase__			=						torch.cuda.amp.autocast(dtype=torch.floataa	)(model.forward	)
         UpperCAmelCase__			=						convert_outputs_to_fpaa(model.forward	)
         UpperCAmelCase__			=						extract_model_from_parallel(__UpperCAmelCase ,						keep_fpaa_wrapper=__UpperCAmelCase	)
         UpperCAmelCase__			=						pickle.dumps(__UpperCAmelCase	)


   @require_cuda
   @require_torch_min_version(version="2.0"	)
   def     lowercase_   (self  :		Optional[int]	)		->       Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__			=						RegressionModel()
         UpperCAmelCase__			=						model.forward
         UpperCAmelCase__			=						torch.cuda.amp.autocast(dtype=torch.floataa	)(model.forward	)
         UpperCAmelCase__			=						convert_outputs_to_fpaa(model.forward	)
         UpperCAmelCase__			=						torch.compile(model.forward ,						backend="inductor"	)
         UpperCAmelCase__			=						torch.randn(4 ,						1_0	).cuda()
         UpperCAmelCase__			=						model(__UpperCAmelCase	)


   def     lowercase_   (self  :		List[Any]	)		->       Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__			=						RegressionModel()
         # could also do a test with DistributedDataParallel, but difficult to run on CPU or single GPU
         UpperCAmelCase__			=						torch.nn.parallel.DataParallel(__UpperCAmelCase	)
         UpperCAmelCase__			=						extract_model_from_parallel(__UpperCAmelCase	)

         self.assertEqual(__UpperCAmelCase ,						__UpperCAmelCase	)


   @require_torch_min_version(version="2.0"	)
   def     lowercase_   (self  :		Union[str, Any]	)		->       Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__			=						RegressionModel()
         UpperCAmelCase__			=						torch.compile(__UpperCAmelCase	)

         # could also do a test with DistributedDataParallel, but difficult to run on CPU or single GPU
         UpperCAmelCase__			=						torch.nn.parallel.DataParallel(__UpperCAmelCase	)
         UpperCAmelCase__			=						torch.compile(__UpperCAmelCase	)
         UpperCAmelCase__			=						extract_model_from_parallel(__UpperCAmelCase	)

         self.assertEqual(compiled_model._orig_mod ,						compiled_model_unwrapped._orig_mod	)





   def     lowercase_   (self  :		int	)		->       int:
         """simple docstring"""



         self.assertEqual(find_device([1, "a", torch.tensor([1, 2, 3]	)]	) ,						torch.device("cpu"	)	)
         self.assertEqual(find_device({"a": 1, "b": torch.tensor([1, 2, 3]	)}	) ,						torch.device("cpu"	)	)
         self.assertIsNone(find_device([1, "a"]	)	)



