'''simple docstring'''





import random
import unittest

import numpy as np

import transformers
from transformers import is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax


if is_flax_available():
 import os

 import jax.numpy as jnp
 from jax import jit

 from transformers import AutoTokenizer, FlaxAutoModelForCausalLM
 from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model

 _lowerCAmelCase  :Optional[int]  				=    '''0.12'''  # assumed parallelism: 8


if is_torch_available():
 import torch


def     __lowerCAmelCase						(       a_       ,      a_       ,      a_=None		)      ->	Any:





     '''simple docstring'''





     if rng is None:
          SCREAMING_SNAKE_CASE					:			Tuple    	=       random.Random()

     SCREAMING_SNAKE_CASE					:			Optional[int]    	=       1
     for dim in shape:
          total_dims *= dim

     SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       []
     for _ in range(UpperCAmelCase__		):
          values.append(rng.randint(0       ,      vocab_size - 1		)		)

     SCREAMING_SNAKE_CASE					:			str    	=       np.array(UpperCAmelCase__       ,      dtype=jnp.intaa		).reshape(UpperCAmelCase__		)

     return output


def     __lowerCAmelCase						(       a_       ,      a_=None		)      ->	Any:





     '''simple docstring'''





     SCREAMING_SNAKE_CASE					:			Any    	=       ids_tensor(UpperCAmelCase__       ,      vocab_size=2       ,      rng=UpperCAmelCase__		)
     # make sure that at least one token is attended to for each batch
     SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       1
     return attn_mask






@require_flax
class 				UpperCAmelCase :




    '''simple docstring'''







    snake_case__							:   int							=						None
    snake_case__							:   Optional[int]							=						()






    def       _UpperCamelCase    (       self )							-> List[Any]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Optional[int]    	=       self.model_tester.prepare_config_and_inputs_for_common()

         # cut to half length & take max batch_size 3
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       2
         SCREAMING_SNAKE_CASE					:			List[str]    	=       inputs['input_ids'].shape[-1] // 2
         SCREAMING_SNAKE_CASE					:			int    	=       inputs['input_ids'][:max_batch_size, :sequence_length]

         SCREAMING_SNAKE_CASE					:			List[str]    	=       jnp.ones_like(__lowerCAmelCase )
         SCREAMING_SNAKE_CASE					:			Tuple    	=       attention_mask[:max_batch_size, :sequence_length]

         # generate max 5 tokens
         SCREAMING_SNAKE_CASE					:			List[str]    	=       input_ids.shape[-1] + 5
         if config.eos_token_id is not None and config.pad_token_id is None:
              # hack to allow generate for models such as GPT2 as is done in `generate()`
              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       config.eos_token_id
         return config, input_ids, attention_mask, max_length






    @is_pt_flax_cross_test
    def       _UpperCamelCase    (       self )							-> List[Any]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			str    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       False
         SCREAMING_SNAKE_CASE					:			List[str]    	=       max_length
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       0

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Dict    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       model_class.__name__[4:]  # Skip the "Flax" at the beginning
              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       getattr(__lowerCAmelCase    ,							__lowerCAmelCase )
              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       pt_model_class(__lowerCAmelCase ).eval()
              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       load_flax_weights_in_pytorch_model(__lowerCAmelCase    ,							flax_model.params )

              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       flax_model.generate(__lowerCAmelCase ).sequences
              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       pt_model.generate(torch.tensor(__lowerCAmelCase    ,							dtype=torch.long ) )

              if flax_generation_outputs.shape[-1] > pt_generation_outputs.shape[-1]:
                   SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       flax_generation_outputs[:, : pt_generation_outputs.shape[-1]]

              self.assertListEqual(pt_generation_outputs.numpy().tolist()    ,							flax_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> Optional[Any]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			List[str]    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Tuple    	=       False
         SCREAMING_SNAKE_CASE					:			str    	=       max_length

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			int    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Tuple    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       jit_generate(__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> str:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			List[Any]    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Tuple    	=       True
         SCREAMING_SNAKE_CASE					:			Any    	=       max_length

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Any    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Dict    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Any    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			List[str]    	=       jit_generate(__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> Union[str, Any]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Optional[int]    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       False
         SCREAMING_SNAKE_CASE					:			List[str]    	=       max_length
         SCREAMING_SNAKE_CASE					:			List[str]    	=       2

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			List[str]    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			List[Any]    	=       jit_generate(__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> Union[str, Any]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Any    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Any    	=       False
         SCREAMING_SNAKE_CASE					:			List[str]    	=       max_length
         SCREAMING_SNAKE_CASE					:			List[str]    	=       2
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       2

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			List[Any]    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[0]    ,							input_ids.shape[0] * config.num_return_sequences )






    def       _UpperCamelCase    (       self )							-> Any:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			List[Any]    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       True
         SCREAMING_SNAKE_CASE					:			Tuple    	=       max_length
         SCREAMING_SNAKE_CASE					:			List[str]    	=       0.8
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       10
         SCREAMING_SNAKE_CASE					:			str    	=       0.3
         SCREAMING_SNAKE_CASE					:			str    	=       1
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       8
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       9

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			List[str]    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			List[str]    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Tuple    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       jit_generate(__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> Tuple:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Tuple    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       max_length
         SCREAMING_SNAKE_CASE					:			int    	=       1
         SCREAMING_SNAKE_CASE					:			List[str]    	=       8
         SCREAMING_SNAKE_CASE					:			Dict    	=       9

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Dict    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			List[str]    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Dict    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			Tuple    	=       jit_generate(__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> List[str]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			List[Any]    	=       self._get_input_ids_and_config()
         SCREAMING_SNAKE_CASE					:			Any    	=       max_length
         SCREAMING_SNAKE_CASE					:			Dict    	=       2
         SCREAMING_SNAKE_CASE					:			Dict    	=       1
         SCREAMING_SNAKE_CASE					:			Tuple    	=       8
         SCREAMING_SNAKE_CASE					:			Any    	=       9

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			int    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Tuple    	=       model.generate(__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Dict    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			Dict    	=       jit_generate(__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> Optional[Any]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       self._get_input_ids_and_config()

         # pad attention mask on the left
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       attention_mask.at[(0, 0)].set(0 )

         SCREAMING_SNAKE_CASE					:			Dict    	=       False
         SCREAMING_SNAKE_CASE					:			int    	=       max_length

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			int    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       model.generate(__lowerCAmelCase    ,							attention_mask=__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			int    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       jit_generate(__lowerCAmelCase    ,							attention_mask=__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> List[str]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			List[Any]    	=       self._get_input_ids_and_config()

         # pad attention mask on the left
         SCREAMING_SNAKE_CASE					:			Any    	=       attention_mask.at[(0, 0)].set(0 )

         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       True
         SCREAMING_SNAKE_CASE					:			int    	=       max_length

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			List[str]    	=       model.generate(__lowerCAmelCase    ,							attention_mask=__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			Any    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			Tuple    	=       jit_generate(__lowerCAmelCase    ,							attention_mask=__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






    def       _UpperCamelCase    (       self )							-> List[str]:
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Any    	=       self._get_input_ids_and_config()

         # pad attention mask on the left
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       attention_mask.at[(0, 0)].set(0 )

         SCREAMING_SNAKE_CASE					:			Any    	=       2
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       max_length

         for model_class in self.all_generative_model_classes:
              SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       model_class(__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			List[str]    	=       model.generate(__lowerCAmelCase    ,							attention_mask=__lowerCAmelCase ).sequences
              self.assertEqual(generation_outputs.shape[-1]    ,							__lowerCAmelCase )

              SCREAMING_SNAKE_CASE					:			str    	=       jit(model.generate )
              SCREAMING_SNAKE_CASE					:			List[Any]    	=       jit_generate(__lowerCAmelCase    ,							attention_mask=__lowerCAmelCase ).sequences

              self.assertListEqual(generation_outputs.tolist()    ,							jit_generation_outputs.tolist() )






@require_flax
class 				UpperCAmelCase (       unittest.TestCase ):




    '''simple docstring'''







    def       _UpperCamelCase    (       self )							-> Dict:
         SCREAMING_SNAKE_CASE					:			int    	=       AutoTokenizer.from_pretrained('hf-internal-testing/tiny-bert' )
         SCREAMING_SNAKE_CASE					:			Tuple    	=       FlaxAutoModelForCausalLM.from_pretrained('hf-internal-testing/tiny-bert-flax-only' )

         SCREAMING_SNAKE_CASE					:			List[Any]    	=       'Hello world'
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       tokenizer(__lowerCAmelCase    ,							return_tensors='np' ).input_ids

         # typos are quickly detected (the correct argument is `do_sample`)
         with self.assertRaisesRegex(__lowerCAmelCase    ,							'do_samples' ):
              model.generate(__lowerCAmelCase    ,							do_samples=__lowerCAmelCase )

         # arbitrary arguments that will not be used anywhere are also not accepted
         with self.assertRaisesRegex(__lowerCAmelCase    ,							'foo' ):
              SCREAMING_SNAKE_CASE					:			Tuple    	=       {'foo': 'bar'}
              model.generate(__lowerCAmelCase    ,							**__lowerCAmelCase )




'''simple docstring'''





import copy
import json
import os
import tempfile

from transformers import is_torch_available

from .test_configuration_utils import config_common_kwargs






class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE ):




    '''simple docstring'''







    def __init__(       self    ,							lowercase__    ,							lowercase__=None    ,							lowercase__=True    ,							lowercase__=None    ,							**lowercase__ )							-> Optional[Any]:
         SCREAMING_SNAKE_CASE					:			int    	=       parent
         SCREAMING_SNAKE_CASE					:			str    	=       config_class
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       has_text_modality
         SCREAMING_SNAKE_CASE					:			Any    	=       kwargs
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       common_properties






    def       _UpperCamelCase    (       self )							-> Union[str, Any]:
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       self.config_class(**self.inputs_dict )
         SCREAMING_SNAKE_CASE					:			int    	=       (
             ['hidden_size', 'num_attention_heads', 'num_hidden_layers']
             if self.common_properties is None
             else self.common_properties
         )

         # Add common fields for text models
         if self.has_text_modality:
              common_properties.extend(['vocab_size'] )

         # Test that config has the common properties as getters
         for prop in common_properties:
              self.parent.assertTrue(hasattr(lowercase__    ,							lowercase__ )    ,							msg=F"""`{prop}` does not exist""" )

         # Test that config has the common properties as setter
         for idx, name in enumerate(lowercase__ ):
              try:
                   setattr(lowercase__    ,							lowercase__    ,							lowercase__ )
                   self.parent.assertEqual(
                       getattr(lowercase__    ,							lowercase__ )    ,							lowercase__    ,							msg=F"""`{name} value {idx} expected, but was {getattr(lowercase__    ,							lowercase__ )}""" )
              except NotImplementedError:
                   # Some models might not be able to implement setters for common_properties
                   # In that case, a NotImplementedError is raised
                   pass

        # Test if config class can be called with Config(prop_name=..)
         for idx, name in enumerate(lowercase__ ):
              try:
                   SCREAMING_SNAKE_CASE					:			Optional[int]    	=       self.config_class(**{name: idx} )
                   self.parent.assertEqual(
                       getattr(lowercase__    ,							lowercase__ )    ,							lowercase__    ,							msg=F"""`{name} value {idx} expected, but was {getattr(lowercase__    ,							lowercase__ )}""" )
              except NotImplementedError:
                   # Some models might not be able to implement setters for common_properties
                   # In that case, a NotImplementedError is raised
                   pass






    def       _UpperCamelCase    (       self )							-> List[str]:
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       self.config_class(**self.inputs_dict )
         SCREAMING_SNAKE_CASE					:			Any    	=       json.loads(config.to_json_string() )
         for key, value in self.inputs_dict.items():
              self.parent.assertEqual(obj[key]    ,							lowercase__ )






    def       _UpperCamelCase    (       self )							-> Optional[int]:
         SCREAMING_SNAKE_CASE					:			Tuple    	=       self.config_class(**self.inputs_dict )

         with tempfile.TemporaryDirectory() as tmpdirname:
              SCREAMING_SNAKE_CASE					:			List[str]    	=       os.path.join(lowercase__    ,							'config.json' )
              config_first.to_json_file(lowercase__ )
              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       self.config_class.from_json_file(lowercase__ )

         self.parent.assertEqual(config_second.to_dict()    ,							config_first.to_dict() )






    def       _UpperCamelCase    (       self )							-> Dict:
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       self.config_class(**self.inputs_dict )

         with tempfile.TemporaryDirectory() as tmpdirname:
              config_first.save_pretrained(lowercase__ )
              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       self.config_class.from_pretrained(lowercase__ )

         self.parent.assertEqual(config_second.to_dict()    ,							config_first.to_dict() )






    def       _UpperCamelCase    (       self )							-> int:
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       self.config_class(**self.inputs_dict )

         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       'test'
         with tempfile.TemporaryDirectory() as tmpdirname:
              SCREAMING_SNAKE_CASE					:			Tuple    	=       os.path.join(lowercase__    ,							lowercase__ )
              config_first.save_pretrained(lowercase__ )
              SCREAMING_SNAKE_CASE					:			Dict    	=       self.config_class.from_pretrained(lowercase__    ,							subfolder=lowercase__ )

         self.parent.assertEqual(config_second.to_dict()    ,							config_first.to_dict() )






    def       _UpperCamelCase    (       self )							-> List[Any]:
         SCREAMING_SNAKE_CASE					:			Dict    	=       self.config_class(**self.inputs_dict    ,							num_labels=5 )
         self.parent.assertEqual(len(config.idalabel )    ,							5 )
         self.parent.assertEqual(len(config.labelaid )    ,							5 )

         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       3
         self.parent.assertEqual(len(config.idalabel )    ,							3 )
         self.parent.assertEqual(len(config.labelaid )    ,							3 )






    def       _UpperCamelCase    (       self )							-> Dict:
         if self.config_class.is_composition:
              return
         SCREAMING_SNAKE_CASE					:			int    	=       self.config_class()
         self.parent.assertIsNotNone(lowercase__ )






    def       _UpperCamelCase    (       self )							-> Tuple:
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       copy.deepcopy(lowercase__ )
         SCREAMING_SNAKE_CASE					:			Any    	=       self.config_class(**lowercase__ )
         SCREAMING_SNAKE_CASE					:			str    	=       []
         for key, value in config_common_kwargs.items():
              if key == "torch_dtype":
                   if not is_torch_available():
                        continue
                   else:
                        import torch

                        if config.torch_dtype != torch.floataa:
                             wrong_values.append(('torch_dtype', config.torch_dtype, torch.floataa) )
              elif getattr(lowercase__    ,							lowercase__ ) != value:
                   wrong_values.append((key, getattr(lowercase__    ,							lowercase__ ), value) )

         if len(lowercase__ ) > 0:
              SCREAMING_SNAKE_CASE					:			List[Any]    	=       '\n'.join([F"""- {v[0]}: got {v[1]} instead of {v[2]}""" for v in wrong_values] )
              raise ValueError(F"""The following keys were not properly set in the config:\n{errors}""" )






    def       _UpperCamelCase    (       self )							-> Optional[int]:
         self.create_and_test_config_common_properties()
         self.create_and_test_config_to_json_string()
         self.create_and_test_config_to_json_file()
         self.create_and_test_config_from_and_save_pretrained()
         self.create_and_test_config_from_and_save_pretrained_subfolder()
         self.create_and_test_config_with_num_labels()
         self.check_config_can_be_init_without_params()
         self.check_config_arguments_init()



