
'''simple docstring'''
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  __A				( unittest.TestCase			):
 def __init__(   self			:    Dict				,   lowerCamelCase			:    Any				,   lowerCamelCase			:    Dict=13				,   lowerCamelCase			:    Optional[int]=7				,   lowerCamelCase			:    Optional[int]=True				,   lowerCamelCase			:    int=True				,   lowerCamelCase			:    Any=True				,   lowerCamelCase			:    Union[str, Any]=True				,   lowerCamelCase			:    Tuple=99				,   lowerCamelCase			:    Optional[int]=32				,   lowerCamelCase			:    List[str]=5				,   lowerCamelCase			:    str=4				,   lowerCamelCase			:    Tuple=37				,   lowerCamelCase			:    List[Any]="gelu"				,   lowerCamelCase			:    List[str]=0.1				,   lowerCamelCase			:    Tuple=0.1				,   lowerCamelCase			:    Union[str, Any]=5_12				,   lowerCamelCase			:    str=16				,   lowerCamelCase			:    Dict=2				,   lowerCamelCase			:    Union[str, Any]=0.02				,   lowerCamelCase			:    Optional[Any]=4				,   ):



   """simple docstring"""





   __A		:     Union[str, Any]												=		parent
   __A		:     Union[str, Any]												=		batch_size
   __A		:     int												=		seq_length
   __A		:     List[str]												=		is_training
   __A		:     Optional[int]												=		use_attention_mask
   __A		:     Dict												=		use_token_type_ids
   __A		:     Union[str, Any]												=		use_labels
   __A		:     str												=		vocab_size
   __A		:     Tuple												=		hidden_size
   __A		:     List[Any]												=		num_hidden_layers
   __A		:     Any												=		num_attention_heads
   __A		:     Optional[Any]												=		intermediate_size
   __A		:     Union[str, Any]												=		hidden_act
   __A		:     Any												=		hidden_dropout_prob
   __A		:     Union[str, Any]												=		attention_probs_dropout_prob
   __A		:     Union[str, Any]												=		max_position_embeddings
   __A		:     Tuple												=		type_vocab_size
   __A		:     Any												=		type_sequence_label_size
   __A		:     str												=		initializer_range
   __A		:     int												=		num_choices
 def 		lowercase_(   self			:    List[str]       ):



   """simple docstring"""





   __A		:     Tuple												=		ids_tensor([self.batch_size, self.seq_length]				,   self.vocab_size       )

   __A		:     str												=		None
   if self.use_attention_mask:
     __A		:     Tuple												=		random_attention_mask([self.batch_size, self.seq_length]       )

   __A		:     Optional[int]												=		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_=lowerCamelCase__				,   )

   return config, input_ids, attention_mask






 def 		lowercase_(   self			:    List[Any]       ):



   """simple docstring"""





   __A		:     Any												=		self.prepare_config_and_inputs()
   __A		:     List[str]												=		config_and_inputs
   __A		:     Tuple												=		{'''input_ids''': input_ids, '''attention_mask''': attention_mask}
   return config, inputs_dict







@require_flax
class  __A				( __lowerCAmelCase    ,						unittest.TestCase			):
 lowerCamelCase				       =(
     (
         FlaxDistilBertModel,
         FlaxDistilBertForMaskedLM,
         FlaxDistilBertForMultipleChoice,
         FlaxDistilBertForQuestionAnswering,
         FlaxDistilBertForSequenceClassification,
         FlaxDistilBertForTokenClassification,
         FlaxDistilBertForQuestionAnswering,
     )
     if is_flax_available()
     else ()
 )
 def 		lowercase_(   self			:    List[Any]       ):



   """simple docstring"""





   __A		:     Optional[Any]												=		FlaxDistilBertModelTester(self       )






 @slow
 def 		lowercase_(   self			:    List[str]       ):



   """simple docstring"""





   for model_class_name in self.all_model_classes:
     __A		:     List[Any]												=		model_class_name.from_pretrained("""distilbert-base-uncased"""       )
     __A		:     List[str]												=		model(np.ones((1, 1)       )       )
     self.assertIsNotNone(lowerCamelCase__       )







@require_flax
class  __A				( unittest.TestCase			):
 @slow
 def 		lowercase_(   self			:    Dict       ):



   """simple docstring"""





   __A		:     Any												=		FlaxDistilBertModel.from_pretrained("""distilbert-base-uncased"""       )
   __A		:     Optional[Any]												=		np.array([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]       )
   __A		:     int												=		np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]       )
   __A		:     Optional[int]												=		model(lowerCamelCase__				,   attention_mask=lowerCamelCase__       )[0]
   __A		:     Optional[int]												=		(1, 11, 7_68)
   self.assertEqual(output.shape				,   lowerCamelCase__       )
   __A		:     Optional[int]												=		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]				,   lowerCamelCase__				,   atol=1e-4       )       )





'''simple docstring'''
A__   :		int 		=8.3_1_4_4_6_2  # Unit - J mol-1 K-1







def        A_     (						__SCREAMING_SNAKE_CASE						:  float			,     __SCREAMING_SNAKE_CASE						:  float			,     __SCREAMING_SNAKE_CASE						:  float )				->       float:





  """simple docstring"""

  if moles < 0 or kelvin < 0 or volume < 0:
    raise ValueError("""Invalid inputs. Enter positive value.""" )
  return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume







def        A_     (						__SCREAMING_SNAKE_CASE						:  float			,     __SCREAMING_SNAKE_CASE						:  float			,     __SCREAMING_SNAKE_CASE						:  float )				->       float:





  """simple docstring"""

  if moles < 0 or kelvin < 0 or pressure < 0:
    raise ValueError("""Invalid inputs. Enter positive value.""" )
  return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure


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

     testmod()



