
"""simple docstring"""




import unittest

from transformers import ErnieMConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        ErnieMForInformationExtraction,
        ErnieMForMultipleChoice,
        ErnieMForQuestionAnswering,
        ErnieMForSequenceClassification,
        ErnieMForTokenClassification,
        ErnieMModel,
    )
    from transformers.models.ernie_m.modeling_ernie_m import ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST







class 						lowercase:



     def __init__(       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE=1_3    ,							__SCREAMING_SNAKE_CASE=7    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=9_9    ,							__SCREAMING_SNAKE_CASE=3_2    ,							__SCREAMING_SNAKE_CASE=5    ,							__SCREAMING_SNAKE_CASE=4    ,							__SCREAMING_SNAKE_CASE=3_7    ,							__SCREAMING_SNAKE_CASE="gelu"    ,							__SCREAMING_SNAKE_CASE=0.1    ,							__SCREAMING_SNAKE_CASE=0.1    ,							__SCREAMING_SNAKE_CASE=5_1_2    ,							__SCREAMING_SNAKE_CASE=1_6    ,							__SCREAMING_SNAKE_CASE=2    ,							__SCREAMING_SNAKE_CASE=0.02    ,							__SCREAMING_SNAKE_CASE=3    ,							__SCREAMING_SNAKE_CASE=4    ,							__SCREAMING_SNAKE_CASE=None    ,							)		->    List[Any]:







         """simple docstring"""



         a__    = parent
         a__    = batch_size
         a__    = seq_length
         a__    = is_training
         a__    = use_input_mask
         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__    = type_vocab_size
         a__    = type_sequence_label_size
         a__    = initializer_range
         a__    = num_labels
         a__    = num_choices
         a__    = scope



     def  lowercase__     (       self      )		->    Optional[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__    = None
         a__    = None
         a__    = None
         if self.use_labels:
             a__    = ids_tensor([self.batch_size]    ,							self.type_sequence_label_size      )
             a__    = ids_tensor([self.batch_size, self.seq_length]    ,							self.num_labels      )
             a__    = ids_tensor([self.batch_size]    ,							self.num_choices      )

         a__    = self.get_config()

         return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels



     def  lowercase__     (       self      )		->    List[str]:







         """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__    = self.get_config()

         return config, input_ids, input_mask



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







         """simple docstring"""



         return ErnieMConfig(
             vocab_size=self.vocab_size    ,							hidden_size=self.hidden_size    ,							num_hidden_layers=self.num_hidden_layers    ,							num_attention_heads=self.num_attention_heads    ,							intermediate_size=self.intermediate_size    ,							hidden_act=self.hidden_act    ,							hidden_dropout_prob=self.hidden_dropout_prob    ,							attention_probs_dropout_prob=self.attention_probs_dropout_prob    ,							max_position_embeddings=self.max_position_embeddings    ,							type_vocab_size=self.type_vocab_size    ,							initializer_range=self.initializer_range    ,							)



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    int:







         """simple docstring"""



         a__    = ErnieMModel(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()
         a__    = model(__SCREAMING_SNAKE_CASE    ,							return_dict=__SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.last_hidden_state.shape    ,							(self.batch_size, self.seq_length, self.hidden_size)      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    Optional[Any]:







         """simple docstring"""



         a__    = ErnieMForQuestionAnswering(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()
         a__    = model(
             __SCREAMING_SNAKE_CASE    ,							attention_mask=__SCREAMING_SNAKE_CASE    ,							start_positions=__SCREAMING_SNAKE_CASE    ,							end_positions=__SCREAMING_SNAKE_CASE    ,							)
         self.parent.assertEqual(result.start_logits.shape    ,							(self.batch_size, self.seq_length)      )
         self.parent.assertEqual(result.end_logits.shape    ,							(self.batch_size, self.seq_length)      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    int:







         """simple docstring"""



         a__    = ErnieMForInformationExtraction(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()
         a__    = torch.ones_like(__SCREAMING_SNAKE_CASE    ,							dtype=torch.floataa      )
         a__    = model(
             __SCREAMING_SNAKE_CASE    ,							attention_mask=__SCREAMING_SNAKE_CASE    ,							start_positions=__SCREAMING_SNAKE_CASE    ,							end_positions=__SCREAMING_SNAKE_CASE    ,							)
         self.parent.assertEqual(result.start_logits.shape    ,							(self.batch_size, self.seq_length)      )
         self.parent.assertEqual(result.end_logits.shape    ,							(self.batch_size, self.seq_length)      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    List[Any]:







         """simple docstring"""



         a__    = self.num_labels
         a__    = ErnieMForSequenceClassification(__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()
         a__    = model(__SCREAMING_SNAKE_CASE    ,							attention_mask=__SCREAMING_SNAKE_CASE    ,							labels=__SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.num_labels)      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    Tuple:







         """simple docstring"""



         a__    = self.num_labels
         a__    = ErnieMForTokenClassification(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()
         input_ids.to(__SCREAMING_SNAKE_CASE      )
         input_mask.to(__SCREAMING_SNAKE_CASE      )
         token_labels.to(__SCREAMING_SNAKE_CASE      )

         a__    = model(__SCREAMING_SNAKE_CASE    ,							attention_mask=__SCREAMING_SNAKE_CASE    ,							labels=__SCREAMING_SNAKE_CASE      )

         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.seq_length, self.num_labels)      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    Optional[int]:







         """simple docstring"""



         a__    = self.num_choices
         a__    = ErnieMForMultipleChoice(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()
         a__    = input_ids.unsqueeze(1      ).expand(-1    ,							self.num_choices    ,							-1      ).contiguous()
         a__    = input_mask.unsqueeze(1      ).expand(-1    ,							self.num_choices    ,							-1      ).contiguous()
         a__    = model(
             __SCREAMING_SNAKE_CASE    ,							attention_mask=__SCREAMING_SNAKE_CASE    ,							labels=__SCREAMING_SNAKE_CASE    ,							)
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.num_choices)      )




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







         """simple docstring"""



         a__    = self.prepare_config_and_inputs()
         (
             (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    
         )    = config_and_inputs
         a__    = {'input_ids': input_ids, 'attention_mask': input_mask}
         return config, inputs_dict







@require_torch
class 						lowercase(_lowercase						,	_lowercase						,	unittest.TestCase					):
     __snake_case:  int  				=    (
         (
             ErnieMModel,
             ErnieMForMultipleChoice,
             ErnieMForQuestionAnswering,
             ErnieMForSequenceClassification,
             ErnieMForTokenClassification,
         )
         if is_torch_available()
         else ()
     )
     __snake_case:  List[str]  				=    ()
     __snake_case:  Tuple  				=    (
         {
             'feature-extraction': ErnieMModel,
             'question-answering': ErnieMForQuestionAnswering,
             'text-classification': ErnieMForSequenceClassification,
             'token-classification': ErnieMForTokenClassification,
             'zero-shot': ErnieMForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     __snake_case:  Optional[int]  				=    False



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )		->    Optional[int]:







         """simple docstring"""



         if pipeline_test_casse_name == "QAPipelineTests":
             return True

         return False



     def  lowercase__     (       self      )		->    Any:







         """simple docstring"""



         a__    = ErnieMModelTester(self      )
         a__    = ConfigTester(self    ,							config_class=__SCREAMING_SNAKE_CASE    ,							hidden_size=3_7      )



     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         self.config_tester.run_common_tests()



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







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE      )



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







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
             a__    = type
             self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE      )



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







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_multiple_choice(*__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    Dict:







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_information_extraction(*__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    Dict:







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*__SCREAMING_SNAKE_CASE      )




     @slow
     def  lowercase__     (       self      )		->    List[Any]:







         """simple docstring"""



         for model_name in ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             a__    = ErnieMModel.from_pretrained(__SCREAMING_SNAKE_CASE      )
             self.assertIsNotNone(__SCREAMING_SNAKE_CASE      )







@require_torch
class 						lowercase(unittest.TestCase					):



     @slow
     def  lowercase__     (       self      )		->    List[str]:







         """simple docstring"""



         a__    = ErnieMModel.from_pretrained('susnato/ernie-m-base_pytorch'      )
         model.eval()
         a__    = torch.tensor([[0, 1, 2, 3, 4, 5]]      )
         a__    = model(__SCREAMING_SNAKE_CASE      )[0]

         # TODO Replace vocab size
         a__    = 7_6_8

         a__    = torch.Size((1, 6, hidden_size)      )
         self.assertEqual(output.shape    ,							__SCREAMING_SNAKE_CASE      )

         a__    = torch.tensor(
             [[[-0.00_12, 0.12_45, -0.02_14], [-0.07_42, 0.02_44, -0.07_71], [-0.03_33, 0.11_64, -0.15_54]]]      )

         self.assertTrue(torch.allclose(output[:, :3, :3]    ,							__SCREAMING_SNAKE_CASE    ,							atol=1e-3      )      )




"""simple docstring"""




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,
)


a		:					Tuple    	=					namedtuple('ExampleNamedTuple', 'a b c')







class 						lowercase(unittest.TestCase					):



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







         """simple docstring"""



         a__    = torch.randn(5    ,							2      )
         a__    = torch.device('cuda'      ) if torch.cuda.is_available() else torch.device('cpu'      )

         a__    = send_to_device(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )
         self.assertTrue(torch.equal(resulta.cpu()    ,							__SCREAMING_SNAKE_CASE      )      )

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

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

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

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



     def  lowercase__     (       self      )		->    Dict:







         """simple docstring"""



         with self.assertRaises(__SCREAMING_SNAKE_CASE      ) as cm:
             a__    = recursively_apply(torch.tensor    ,							(torch.tensor(1      ), 1)    ,							error_on_other_type=__SCREAMING_SNAKE_CASE      )
         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      )		->    Any:







         """simple docstring"""



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

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

         a__    = 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(__SCREAMING_SNAKE_CASE      )    ,							[[[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      )		->    str:







         """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      )		->    Tuple:







         """simple docstring"""



         a__    = RegressionModel()
         a__    = model.forward
         a__    = convert_outputs_to_fpaa(model.forward      )
         a__    = extract_model_from_parallel(__SCREAMING_SNAKE_CASE    ,							keep_fpaa_wrapper=__SCREAMING_SNAKE_CASE      )
         a__    = pickle.dumps(__SCREAMING_SNAKE_CASE      )



     @require_cuda
     def  lowercase__     (       self      )		->    Union[str, Any]:







         """simple docstring"""



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



     @require_cuda
     @require_torch_min_version(version='2.0'      )
     def  lowercase__     (       self      )		->    Optional[int]:







         """simple docstring"""



         a__    = RegressionModel()
         a__    = model.forward
         a__    = torch.cuda.amp.autocast(dtype=torch.floataa      )(model.forward      )
         a__    = convert_outputs_to_fpaa(model.forward      )
         a__    = torch.compile(model.forward    ,							backend='inductor'      )
         a__    = torch.randn(4    ,							1_0      ).cuda()
         a__    = model(__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    str:







         """simple docstring"""



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

         self.assertEqual(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )



     @require_torch_min_version(version='2.0'      )
     def  lowercase__     (       self      )		->    str:







         """simple docstring"""



         a__    = RegressionModel()
         a__    = torch.compile(__SCREAMING_SNAKE_CASE      )

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

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




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







         """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']      )      )


