

import unittest

from transformers import BigBirdConfig, 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():
				import jax

				from transformers.models.big_bird.modeling_flax_big_bird import (
				    FlaxBigBirdForCausalLM,
				    FlaxBigBirdForMaskedLM,
				    FlaxBigBirdForMultipleChoice,
				    FlaxBigBirdForPreTraining,
				    FlaxBigBirdForQuestionAnswering,
				    FlaxBigBirdForSequenceClassification,
				    FlaxBigBirdForTokenClassification,
				    FlaxBigBirdModel,
				)

class     __UpperCamelCase     (       unittest.TestCase    ):




	def __init__(		self						:    str		,						lowerCAmelCase						:    Dict		,						lowerCAmelCase						:    int=2		,						lowerCAmelCase						:    List[str]=56		,						lowerCAmelCase						:    Tuple=True		,						lowerCAmelCase						:    Tuple=True		,						lowerCAmelCase						:    Dict=True		,						lowerCAmelCase						:    int=True		,						lowerCAmelCase						:    List[Any]=99		,						lowerCAmelCase						:    Union[str, Any]=32		,						lowerCAmelCase						:    Tuple=2		,						lowerCAmelCase						:    Tuple=2		,						lowerCAmelCase						:    Union[str, Any]=7		,						lowerCAmelCase						:    str="gelu_new"		,						lowerCAmelCase						:    Any=0.1		,						lowerCAmelCase						:    List[str]=0.1		,						lowerCAmelCase						:    Optional[int]=512		,						lowerCAmelCase						:    Dict=16		,						lowerCAmelCase						:    Optional[int]=2		,						lowerCAmelCase						:    int=0.02		,						lowerCAmelCase						:    Optional[Any]=4		,						lowerCAmelCase						:    int="block_sparse"		,						lowerCAmelCase						:    Tuple=True		,						lowerCAmelCase						:    Union[str, Any]=False		,						lowerCAmelCase						:    Optional[Any]=2		,						lowerCAmelCase						:    int=3		,						):


		'''simple docstring'''







		UpperCAmelCase_												=      parent
		UpperCAmelCase_												=      batch_size
		UpperCAmelCase_												=      seq_length
		UpperCAmelCase_												=      is_training
		UpperCAmelCase_												=      use_attention_mask
		UpperCAmelCase_												=      use_token_type_ids
		UpperCAmelCase_												=      use_labels
		UpperCAmelCase_												=      vocab_size
		UpperCAmelCase_												=      hidden_size
		UpperCAmelCase_												=      num_hidden_layers
		UpperCAmelCase_												=      num_attention_heads
		UpperCAmelCase_												=      intermediate_size
		UpperCAmelCase_												=      hidden_act
		UpperCAmelCase_												=      hidden_dropout_prob
		UpperCAmelCase_												=      attention_probs_dropout_prob
		UpperCAmelCase_												=      max_position_embeddings
		UpperCAmelCase_												=      type_vocab_size
		UpperCAmelCase_												=      type_sequence_label_size
		UpperCAmelCase_												=      initializer_range
		UpperCAmelCase_												=      num_choices

		UpperCAmelCase_												=      rescale_embeddings
		UpperCAmelCase_												=      attention_type
		UpperCAmelCase_												=      use_bias
		UpperCAmelCase_												=      block_size
		UpperCAmelCase_												=      num_random_blocks




	def    __A       (		self						:    Optional[Any]				):


		'''simple docstring'''







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

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

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

		UpperCAmelCase_												=      BigBirdConfig(
		    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		,						is_decoder=A__		,						initializer_range=self.initializer_range		,						attention_type=self.attention_type		,						block_size=self.block_size		,						num_random_blocks=self.num_random_blocks		,						use_bias=self.use_bias		,						rescale_embeddings=self.rescale_embeddings		,						)

		return config, input_ids, token_type_ids, attention_mask




	def    __A       (		self						:    Optional[Any]				):


		'''simple docstring'''







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


@require_flax
class     __UpperCamelCase     (       __snake_case  ,  unittest.TestCase    ):
	SCREAMING_SNAKE_CASE__     					=  (
	    (
	        FlaxBigBirdForCausalLM,
	        FlaxBigBirdModel,
	        FlaxBigBirdForPreTraining,
	        FlaxBigBirdForMaskedLM,
	        FlaxBigBirdForMultipleChoice,
	        FlaxBigBirdForQuestionAnswering,
	        FlaxBigBirdForSequenceClassification,
	        FlaxBigBirdForTokenClassification,
	    )
	    if is_flax_available()
	    else ()
	)

	SCREAMING_SNAKE_CASE__     					=  False
	SCREAMING_SNAKE_CASE__     					=  False




	def    __A       (		self						:    Tuple				):


		'''simple docstring'''







		UpperCAmelCase_												=      FlaxBigBirdModelTester(self				)




	@slow
	# copied from `test_modeling_flax_common` because it takes much longer than other models
	def    __A       (		self						:    Tuple				):


		'''simple docstring'''







		super().test_from_pretrained_save_pretrained()




	@slow
	# copied from `test_modeling_flax_common` because it takes much longer than other models
	def    __A       (		self						:    Optional[Any]				):


		'''simple docstring'''







		super().test_from_pretrained_with_no_automatic_init()




	@slow
	# copied from `test_modeling_flax_common` because it takes much longer than other models
	def    __A       (		self						:    Optional[int]				):


		'''simple docstring'''







		super().test_no_automatic_init()




	@slow
	# copied from `test_modeling_flax_common` because it takes much longer than other models
	def    __A       (		self						:    Any				):


		'''simple docstring'''







		super().test_hidden_states_output()




	@slow
	def    __A       (		self						:    List[Any]				):


		'''simple docstring'''







		for model_class_name in self.all_model_classes:
			UpperCAmelCase_												=      model_class_name.from_pretrained("google/bigbird-roberta-base"				)
			self.assertIsNotNone(A__				)




	def    __A       (		self						:    List[str]				):


		'''simple docstring'''







		if self.test_attn_probs:
			super().test_attention_outputs()




	@slow
	# copied from `test_modeling_flax_common` because it takes much longer than other models
	def    __A       (		self						:    Optional[Any]				):


		'''simple docstring'''







		UpperCAmelCase_												=      self.model_tester.prepare_config_and_inputs_for_common()

		for model_class in self.all_model_classes:
			with self.subTest(model_class.__name__				):
				UpperCAmelCase_												=      self._prepare_for_class(A__		,						A__				)
				UpperCAmelCase_												=      model_class(A__				)

				@jax.jit
				def model_jitted(lowerCAmelCase						:    List[str]		,						lowerCAmelCase						:    str=None		,						**lowerCAmelCase						:    List[str]				):
					return model(input_ids=A__		,						attention_mask=A__		,						**A__				)

				with self.subTest("JIT Enabled"				):
					UpperCAmelCase_												=      model_jitted(**A__				).to_tuple()

				with self.subTest("JIT Disabled"				):
					with jax.disable_jit():
						UpperCAmelCase_												=      model_jitted(**A__				).to_tuple()

				self.assertEqual(len(A__				)		,						len(A__				)				)
				for jitted_output, output in zip(A__		,						A__				):
					self.assertEqual(jitted_output.shape		,						output.shape				)




	def    __A       (		self						:    Dict		,						lowerCAmelCase						:    int		,						lowerCAmelCase						:    Optional[Any]		,						lowerCAmelCase						:    List[str]		,						lowerCAmelCase						:    Dict=1e-5		,						lowerCAmelCase						:    Optional[int]="outputs"		,						lowerCAmelCase						:    Any=None				):


		'''simple docstring'''







		if name.startswith("outputs.attentions"				):
			return
		else:
			super().check_pt_flax_outputs(A__		,						A__		,						A__		,						A__		,						A__		,						A__				)







from collections import defaultdict



def  a__ (__lowercase							:str					,  __lowercase							:str   )		-> bool:
				_A	:				Union[str, Any]   =      first_str.lower().strip()
				_A	:				int   =      second_str.lower().strip()

				# Remove whitespace
				_A	:				int   =      first_str.replace(''' '''					,  ''''''   )
				_A	:				Optional[Any]   =      second_str.replace(''' '''					,  ''''''   )

				# Strings of different lengths are not anagrams
				if len(__lowercase   ) != len(__lowercase   ):
								return False

				# Default values for count should be 0
				_A	:				defaultdict[str, int]   =      defaultdict(__lowercase   )

				# For each character in input strings,
				# increment count in the corresponding
				for i in range(len(__lowercase   )   ):
								count[first_str[i]] += 1
								count[second_str[i]] -= 1

				return all(_count == 0 for _count in count.values()   )


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

	testmod()
	_UpperCamelCase			:	Dict								=input('Enter the first string ').strip()
	_UpperCamelCase			:	Union[str, Any]								=input('Enter the second string ').strip()

	_UpperCamelCase			:	Dict								=check_anagrams(input_a, input_b)
	print(f'''{input_a} and {input_b} are {"" if status else "not "}anagrams.''')



