



'''simple docstring'''


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 	UpperCAmelCase	(		unittest.TestCase):


 '''simple docstring'''




 def __init__(   self							,  lowerCAmelCase_							,  lowerCAmelCase_=1_3							,  lowerCAmelCase_=7							,  lowerCAmelCase_=True							,  lowerCAmelCase_=True							,  lowerCAmelCase_=True							,  lowerCAmelCase_=True							,  lowerCAmelCase_=9_9							,  lowerCAmelCase_=3_2							,  lowerCAmelCase_=5							,  lowerCAmelCase_=4							,  lowerCAmelCase_=3_7							,  lowerCAmelCase_="gelu"							,  lowerCAmelCase_=0.1							,  lowerCAmelCase_=0.1							,  lowerCAmelCase_=5_1_2							,  lowerCAmelCase_=1_6							,  lowerCAmelCase_=2							,  lowerCAmelCase_=0.0_2							,  lowerCAmelCase_=4							,  ) ->      Union[str, Any]:



      """simple docstring"""







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




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



      """simple docstring"""







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

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

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

      a_       		=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=lowerCAmelCase_							,  initializer_range=self.initializer_range							,  )

      return config, input_ids, token_type_ids, attention_mask




 def       lowercase_  (   self) ->      Dict:



      """simple docstring"""







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




 def       lowercase_  (   self) ->      int:



      """simple docstring"""







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

      a_       		=True
      a_       		=floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
      a_       		=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 	UpperCAmelCase	(		__a					,	unittest.TestCase):


 '''simple docstring'''




 __magic_name__					: str  =      True

 __magic_name__					: str  =      (
     (
         FlaxBertModel,
         FlaxBertForPreTraining,
         FlaxBertForMaskedLM,
         FlaxBertForMultipleChoice,
         FlaxBertForQuestionAnswering,
         FlaxBertForNextSentencePrediction,
         FlaxBertForSequenceClassification,
         FlaxBertForTokenClassification,
         FlaxBertForQuestionAnswering,
     )
     if is_flax_available()
     else ()
 )




 def       lowercase_  (   self) ->      int:



      """simple docstring"""







      a_       		=FlaxBertModelTester(self)




 @slow
 def       lowercase_  (   self) ->      Tuple:



      """simple docstring"""







      a_       		=FlaxBertModel.from_pretrained("bert-base-cased")
      a_       		=model(np.ones((1, 1)))
      self.assertIsNotNone(lowerCAmelCase_)







'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase							       =			{
    '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase							       =			[
      '''TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''TimesformerModel''',
      '''TimesformerForVideoClassification''',
      '''TimesformerPreTrainedModel''',
  ]

if TYPE_CHECKING:
  from .configuration_timesformer import TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, TimesformerConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_timesformer import (
        TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        TimesformerForVideoClassification,
        TimesformerModel,
        TimesformerPreTrainedModel,
    )

else:
  import sys

  lowercase							       =			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


