
__a        = {
    '0000': '0',
    '0001': '1',
    '0010': '2',
    '0011': '3',
    '0100': '4',
    '0101': '5',
    '0110': '6',
    '0111': '7',
    '1000': '8',
    '1001': '9',
    '1010': 'a',
    '1011': 'b',
    '1100': 'c',
    '1101': 'd',
    '1110': 'e',
    '1111': 'f',
}




def     a						(							snake_case__: str ):


    '''simple docstring'''
    lowercase_					  = str(snake_case__ ).strip()

    # Exceptions
    if not binary_str:
        raise ValueError('''Empty string was passed to the function''' )
    lowercase_					  = binary_str[0] == '''-'''
    lowercase_					  = binary_str[1:] if is_negative else binary_str
    if not all(char in '''01''' for char in binary_str ):
        raise ValueError('''Non-binary value was passed to the function''' )

    lowercase_					  = (
        '''0''' * (4 * (divmod(len(snake_case__ )						,       4 )[0] + 1) - len(snake_case__ )) + binary_str
    )

    lowercase_					  = []
    for x in range(0						,       len(snake_case__ )						,       4 ):
        hexadecimal.append(BITS_TO_HEX[binary_str[x : x + 4]] )
    lowercase_					  = '''0x''' + ''''''.join(snake_case__ )

    return "-" + hexadecimal_str if is_negative else hexadecimal_str


if __name__ == "__main__":
      from doctest import testmod

      testmod()






import unittest

import numpy as np

from transformers import ElectraConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
						from transformers.models.electra.modeling_flax_electra import (
						    FlaxElectraForCausalLM,
						    FlaxElectraForMaskedLM,
						    FlaxElectraForMultipleChoice,
						    FlaxElectraForPreTraining,
						    FlaxElectraForQuestionAnswering,
						    FlaxElectraForSequenceClassification,
						    FlaxElectraForTokenClassification,
						    FlaxElectraModel,
						)
class 			lowercase__(    unittest.TestCase							):



	"""simple docstring"""




	def __init__(	self  :      str	,							SCREAMING_SNAKE_CASE_  :      str	,							SCREAMING_SNAKE_CASE_  :      Optional[int]=1_3	,							SCREAMING_SNAKE_CASE_  :      int=7	,							SCREAMING_SNAKE_CASE_  :      Tuple=True	,							SCREAMING_SNAKE_CASE_  :      List[Any]=True	,							SCREAMING_SNAKE_CASE_  :      List[Any]=True	,							SCREAMING_SNAKE_CASE_  :      Dict=True	,							SCREAMING_SNAKE_CASE_  :      Optional[Any]=9_9	,							SCREAMING_SNAKE_CASE_  :      Any=2_4	,							SCREAMING_SNAKE_CASE_  :      int=3_2	,							SCREAMING_SNAKE_CASE_  :      Any=5	,							SCREAMING_SNAKE_CASE_  :      List[str]=4	,							SCREAMING_SNAKE_CASE_  :      Optional[int]=3_7	,							SCREAMING_SNAKE_CASE_  :      Optional[int]="gelu"	,							SCREAMING_SNAKE_CASE_  :      Any=0.1	,							SCREAMING_SNAKE_CASE_  :      List[Any]=0.1	,							SCREAMING_SNAKE_CASE_  :      Dict=5_1_2	,							SCREAMING_SNAKE_CASE_  :      Optional[int]=1_6	,							SCREAMING_SNAKE_CASE_  :      List[Any]=2	,							SCREAMING_SNAKE_CASE_  :      List[str]=0.02	,							SCREAMING_SNAKE_CASE_  :      List[str]=4	,							)	->					Optional[int]:
					lowercase_					  = parent
					lowercase_					  = batch_size
					lowercase_					  = seq_length
					lowercase_					  = is_training
					lowercase_					  = use_attention_mask
					lowercase_					  = use_token_type_ids
					lowercase_					  = use_labels
					lowercase_					  = vocab_size
					lowercase_					  = hidden_size
					lowercase_					  = embedding_size
					lowercase_					  = num_hidden_layers
					lowercase_					  = num_attention_heads
					lowercase_					  = intermediate_size
					lowercase_					  = hidden_act
					lowercase_					  = hidden_dropout_prob
					lowercase_					  = attention_probs_dropout_prob
					lowercase_					  = max_position_embeddings
					lowercase_					  = type_vocab_size
					lowercase_					  = type_sequence_label_size
					lowercase_					  = initializer_range
					lowercase_					  = num_choices
	def 						_lowercase  (	self  :      Optional[int]	)	->					Tuple:
					lowercase_					  = ids_tensor([self.batch_size, self.seq_length]	,							self.vocab_size	)

					lowercase_					  = None
					if self.use_attention_mask:
									lowercase_					  = random_attention_mask([self.batch_size, self.seq_length]	)

					lowercase_					  = None
					if self.use_token_type_ids:
									lowercase_					  = ids_tensor([self.batch_size, self.seq_length]	,							self.type_vocab_size	)

					lowercase_					  = ElectraConfig(
					    vocab_size=self.vocab_size	,							hidden_size=self.hidden_size	,							embedding_size=self.embedding_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	,							)

					return config, input_ids, token_type_ids, attention_mask




	def 						_lowercase  (	self  :      Any	)	->					str:
					lowercase_					  = self.prepare_config_and_inputs()
					lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_					  = config_and_inputs
					lowercase_					  = {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
					return config, inputs_dict

@require_flax
class 			lowercase__(    UpperCAmelCase			,						unittest.TestCase							):



	"""simple docstring"""




	a      :List[str]   					=     True

	a      :List[Any]   					=     (
	    (
	        FlaxElectraModel,
	        FlaxElectraForCausalLM,
	        FlaxElectraForMaskedLM,
	        FlaxElectraForPreTraining,
	        FlaxElectraForTokenClassification,
	        FlaxElectraForQuestionAnswering,
	        FlaxElectraForMultipleChoice,
	        FlaxElectraForSequenceClassification,
	    )
	    if is_flax_available()
	    else ()
	)
	def 						_lowercase  (	self  :      List[str]	)	->					Optional[Any]:
					lowercase_					  = FlaxElectraModelTester(self	)




	@slow
	def 						_lowercase  (	self  :      List[str]	)	->					int:
					for model_class_name in self.all_model_classes:
									if model_class_name == FlaxElectraForMaskedLM:
													lowercase_					  = model_class_name.from_pretrained('''google/electra-small-generator'''	)
									else:
													lowercase_					  = model_class_name.from_pretrained('''google/electra-small-discriminator'''	)
									lowercase_					  = model(np.ones((1, 1)	)	)
									self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)




