

import unittest

import numpy as np

from transformers import DistilBertConfig, 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.numpy as jnp

				from transformers.models.distilbert.modeling_flax_distilbert import (
				    FlaxDistilBertForMaskedLM,
				    FlaxDistilBertForMultipleChoice,
				    FlaxDistilBertForQuestionAnswering,
				    FlaxDistilBertForSequenceClassification,
				    FlaxDistilBertForTokenClassification,
				    FlaxDistilBertModel,
				)

class     __UpperCamelCase     (       unittest.TestCase    ):




	def __init__(		self						:    List[Any]		,						lowerCAmelCase						:    List[str]		,						lowerCAmelCase						:    List[Any]=13		,						lowerCAmelCase						:    Optional[Any]=7		,						lowerCAmelCase						:    List[Any]=True		,						lowerCAmelCase						:    Union[str, Any]=True		,						lowerCAmelCase						:    Dict=True		,						lowerCAmelCase						:    List[Any]=True		,						lowerCAmelCase						:    Union[str, Any]=99		,						lowerCAmelCase						:    int=32		,						lowerCAmelCase						:    Any=5		,						lowerCAmelCase						:    Optional[int]=4		,						lowerCAmelCase						:    Tuple=37		,						lowerCAmelCase						:    Any="gelu"		,						lowerCAmelCase						:    int=0.1		,						lowerCAmelCase						:    Tuple=0.1		,						lowerCAmelCase						:    Tuple=512		,						lowerCAmelCase						:    Union[str, Any]=16		,						lowerCAmelCase						:    str=2		,						lowerCAmelCase						:    Any=0.02		,						lowerCAmelCase						:    Tuple=4		,						):


		'''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




	def    __A       (		self						:    int				):


		'''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_												=      DistilBertConfig(
		    vocab_size=self.vocab_size		,						dim=self.hidden_size		,						n_layers=self.num_hidden_layers		,						n_heads=self.num_attention_heads		,						hidden_dim=self.intermediate_size		,						hidden_act=self.hidden_act		,						dropout=self.hidden_dropout_prob		,						attention_dropout=self.attention_probs_dropout_prob		,						max_position_embeddings=self.max_position_embeddings		,						initializer_range=self.initializer_range		,						tie_weights_=A__		,						)

		return config, input_ids, attention_mask




	def    __A       (		self						:    Dict				):


		'''simple docstring'''







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


@require_flax
class     __UpperCamelCase     (       __snake_case  ,  unittest.TestCase    ):
	SCREAMING_SNAKE_CASE__     					=  (
	    (
	        FlaxDistilBertModel,
	        FlaxDistilBertForMaskedLM,
	        FlaxDistilBertForMultipleChoice,
	        FlaxDistilBertForQuestionAnswering,
	        FlaxDistilBertForSequenceClassification,
	        FlaxDistilBertForTokenClassification,
	        FlaxDistilBertForQuestionAnswering,
	    )
	    if is_flax_available()
	    else ()
	)




	def    __A       (		self						:    Any				):


		'''simple docstring'''







		UpperCAmelCase_												=      FlaxDistilBertModelTester(self				)




	@slow
	def    __A       (		self						:    Dict				):


		'''simple docstring'''







		for model_class_name in self.all_model_classes:
			UpperCAmelCase_												=      model_class_name.from_pretrained("distilbert-base-uncased"				)
			UpperCAmelCase_												=      model(np.ones((1, 1)				)				)
			self.assertIsNotNone(A__				)


@require_flax
class     __UpperCamelCase     (       unittest.TestCase    ):




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


		'''simple docstring'''







		UpperCAmelCase_												=      FlaxDistilBertModel.from_pretrained("distilbert-base-uncased"				)
		UpperCAmelCase_												=      np.array([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]]				)
		UpperCAmelCase_												=      np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]				)
		UpperCAmelCase_												=      model(A__		,						attention_mask=A__				)[0]
		UpperCAmelCase_												=      (1, 11, 768)
		self.assertEqual(output.shape		,						A__				)
		UpperCAmelCase_												=      np.array([[[-0.1_639, 0.3_299, 0.1_648], [-0.1_746, 0.3_289, 0.1_710], [-0.1_884, 0.3_357, 0.1_810]]]				)

		self.assertTrue(jnp.allclose(output[:, 1:4, 1:4]		,						A__		,						atol=1e-4				)				)







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.''')



