






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			):






 '''simple docstring'''




 def __init__(	self							,  _A							,  _A=13							,  _A=7							,  _A=True							,  _A=True							,  _A=True							,  _A=True							,  _A=99							,  _A=32							,  _A=5							,  _A=4							,  _A=37							,  _A="gelu"							,  _A=0.1							,  _A=0.1							,  _A=512							,  _A=16							,  _A=2							,  _A=0.02							,  _A=4							,  ) ->		Any:

     """simple docstring"""



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


 def  snake_case__				(	self) ->		str:

     """simple docstring"""



     _UpperCAmelCase				:      Optional[int]			  =				ids_tensor([self.batch_size, self.seq_length]							,  self.vocab_size)

     _UpperCAmelCase				:      Optional[Any]			  =				None
     if self.use_attention_mask:
         _UpperCAmelCase				:      str			  =				random_attention_mask([self.batch_size, self.seq_length])

     _UpperCAmelCase				:      Optional[Any]			  =				None
     if self.use_token_type_ids:
         _UpperCAmelCase				:      List[Any]			  =				ids_tensor([self.batch_size, self.seq_length]							,  self.type_vocab_size)

     _UpperCAmelCase				:      Tuple			  =				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  snake_case__				(	self) ->		Optional[int]:

     """simple docstring"""



     _UpperCAmelCase				:      str			  =				self.prepare_config_and_inputs()
     _UpperCAmelCase  , _UpperCAmelCase  , _UpperCAmelCase  , _UpperCAmelCase				:      int			  =				config_and_inputs
     _UpperCAmelCase				:      Dict			  =				{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
     return config, inputs_dict


 def  snake_case__				(	self) ->		int:

     """simple docstring"""



     _UpperCAmelCase				:      int			  =				self.prepare_config_and_inputs()
     _UpperCAmelCase  , _UpperCAmelCase  , _UpperCAmelCase  , _UpperCAmelCase				:      Optional[int]			  =				config_and_inputs

     _UpperCAmelCase				:      Dict			  =				True
     _UpperCAmelCase				:      Any			  =				floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
     _UpperCAmelCase				:      int			  =				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_    (						__lowercase ,   unittest.TestCase			):






 '''simple docstring'''




 _SCREAMING_SNAKE_CASE							:			str =					True

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


 def  snake_case__				(	self) ->		List[Any]:

     """simple docstring"""



     _UpperCAmelCase				:      List[str]			  =				FlaxBertModelTester(self)


 @slow
 def  snake_case__				(	self) ->		Optional[int]:

     """simple docstring"""



     _UpperCAmelCase				:      List[Any]			  =				FlaxBertModel.from_pretrained('''bert-base-cased''')
     _UpperCAmelCase				:      Any			  =				model(np.ones((1, 1)))
     self.assertIsNotNone(_A)












import unittest

from knapsack import knapsack as k
class 							A_    (						unittest.TestCase			):






 '''simple docstring'''




 def  snake_case__				(	self) ->		Dict:

     """simple docstring"""



     _UpperCAmelCase				:      Optional[int]			  =				0
     _UpperCAmelCase				:      List[Any]			  =				[0]
     _UpperCAmelCase				:      Optional[Any]			  =				[0]
     _UpperCAmelCase				:      Optional[int]			  =				len(_A)
     self.assertEqual(k.knapsack(_A							,  _A							,  _A							,  _A)							,  0)

     _UpperCAmelCase				:      Optional[int]			  =				[60]
     _UpperCAmelCase				:      List[str]			  =				[10]
     _UpperCAmelCase				:      str			  =				len(_A)
     self.assertEqual(k.knapsack(_A							,  _A							,  _A							,  _A)							,  0)


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

     """simple docstring"""



     _UpperCAmelCase				:      Any			  =				3
     _UpperCAmelCase				:      int			  =				[1, 2, 3]
     _UpperCAmelCase				:      List[str]			  =				[3, 2, 1]
     _UpperCAmelCase				:      Union[str, Any]			  =				len(_A)
     self.assertEqual(k.knapsack(_A							,  _A							,  _A							,  _A)							,  5)


 def  snake_case__				(	self) ->		Tuple:

     """simple docstring"""



     _UpperCAmelCase				:      List[str]			  =				50
     _UpperCAmelCase				:      Tuple			  =				[60, 100, 120]
     _UpperCAmelCase				:      Optional[int]			  =				[10, 20, 30]
     _UpperCAmelCase				:      Optional[Any]			  =				len(_A)
     self.assertEqual(k.knapsack(_A							,  _A							,  _A							,  _A)							,  220)


if __name__ == "__main__":
  unittest.main()




