


import unittest

import numpy as np

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

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
							from transformers.models.bert.modeling_flax_bert import (
							    FlaxBertForMaskedLM,
							    FlaxBertForMultipleChoice,
							    FlaxBertForNextSentencePrediction,
							    FlaxBertForPreTraining,
							    FlaxBertForQuestionAnswering,
							    FlaxBertForSequenceClassification,
							    FlaxBertForTokenClassification,
							    FlaxBertModel,
							)

class 						A__							(		unittest.TestCase  ):




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


										"""simple docstring"""





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




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


										"""simple docstring"""





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

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

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

										_SCREAMING_SNAKE_CASE			  =BertConfig(
										    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				,    )

										return config, input_ids, token_type_ids, attention_mask




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


										"""simple docstring"""





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




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


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.prepare_config_and_inputs()
										_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE			  =config_and_inputs

										_SCREAMING_SNAKE_CASE			  =True
										_SCREAMING_SNAKE_CASE			  =floats_tensor([self.batch_size, self.seq_length, self.hidden_size]  )
										_SCREAMING_SNAKE_CASE			  =ids_tensor([self.batch_size, self.seq_length]				,    vocab_size=2  )

										return (
										    config,
										    input_ids,
										    attention_mask,
										    encoder_hidden_states,
										    encoder_attention_mask,
										)

@require_flax
class 						A__							(		UpperCamelCase__   ,     unittest.TestCase  ):
						UpperCAmelCase             =						True

						UpperCAmelCase             =						(
						    (
						        FlaxBertModel,
						        FlaxBertForPreTraining,
						        FlaxBertForMaskedLM,
						        FlaxBertForMultipleChoice,
						        FlaxBertForQuestionAnswering,
						        FlaxBertForNextSentencePrediction,
						        FlaxBertForSequenceClassification,
						        FlaxBertForTokenClassification,
						        FlaxBertForQuestionAnswering,
						    )
						    if is_flax_available()
						    else ()
						)




						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     int:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =FlaxBertModelTester(self  )




						@slow
						def 							__UpperCamelCase				(       self					:      int  )							->     int:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =FlaxBertModel.from_pretrained('''bert-base-cased'''  )
										_SCREAMING_SNAKE_CASE			  =model(np.ones((1, 1)  )  )
										self.assertIsNotNone(_a  )



import os
import unittest

from transformers import LxmertTokenizer, LxmertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class 						A__							(		UpperCamelCase__   ,     unittest.TestCase  ):
						UpperCAmelCase             =						LxmertTokenizer
						UpperCAmelCase             =						LxmertTokenizerFast
						UpperCAmelCase             =						True
						UpperCAmelCase             =						True




						def 							__UpperCamelCase				(       self					:      Optional[int]  )							->     Tuple:


										"""simple docstring"""





										super().setUp()

										_SCREAMING_SNAKE_CASE			  =[
										    '''[UNK]''',
										    '''[CLS]''',
										    '''[SEP]''',
										    '''want''',
										    '''##want''',
										    '''##ed''',
										    '''wa''',
										    '''un''',
										    '''runn''',
										    '''##ing''',
										    ''',''',
										    '''low''',
										    '''lowest''',
										]
										_SCREAMING_SNAKE_CASE			  =os.path.join(self.tmpdirname				,    VOCAB_FILES_NAMES['''vocab_file''']  )
										with open(self.vocab_file				,    '''w'''				,    encoding='''utf-8'''  ) as vocab_writer:
														vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]  )  )




						def 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      Tuple  )							->     Optional[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  ='''UNwant\u00E9d,running'''
										_SCREAMING_SNAKE_CASE			  ='''unwanted, running'''
										return input_text, output_text




						def 							__UpperCamelCase				(       self					:      Tuple  )							->     List[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.tokenizer_class(self.vocab_file  )

										_SCREAMING_SNAKE_CASE			  =tokenizer.tokenize('''UNwant\u00E9d,running'''  )
										self.assertListEqual(_a				,    ['''un''', '''##want''', '''##ed''', ''',''', '''runn''', '''##ing''']  )
										self.assertListEqual(tokenizer.convert_tokens_to_ids(_a  )				,    [7, 4, 5, 10, 8, 9]  )




						def 							__UpperCamelCase				(       self					:      Dict  )							->     List[Any]:


										"""simple docstring"""





										if not self.test_rust_tokenizer:
														return

										_SCREAMING_SNAKE_CASE			  =self.get_tokenizer()
										_SCREAMING_SNAKE_CASE			  =self.get_rust_tokenizer()

										_SCREAMING_SNAKE_CASE			  ='''I was born in 92000, and this is falsé.'''

										_SCREAMING_SNAKE_CASE			  =tokenizer.tokenize(_a  )
										_SCREAMING_SNAKE_CASE			  =rust_tokenizer.tokenize(_a  )
										self.assertListEqual(_a				,    _a  )

										_SCREAMING_SNAKE_CASE			  =tokenizer.encode(_a				,    add_special_tokens=_a  )
										_SCREAMING_SNAKE_CASE			  =rust_tokenizer.encode(_a				,    add_special_tokens=_a  )
										self.assertListEqual(_a				,    _a  )

										_SCREAMING_SNAKE_CASE			  =self.get_rust_tokenizer()
										_SCREAMING_SNAKE_CASE			  =tokenizer.encode(_a  )
										_SCREAMING_SNAKE_CASE			  =rust_tokenizer.encode(_a  )
										self.assertListEqual(_a				,    _a  )