
from __future__ import annotations

import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_tf, slow
from transformers.utils import is_tf_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask


if is_tf_available():
      import tensorflow as tf

      from transformers import TFBlipTextModel
      from transformers.models.blip.modeling_tf_blip import TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST



class 		UpperCamelCase__  :
   def __init__(self			: Optional[int] ,    snake_case_			: List[Any] ,    snake_case_			: Optional[int]=1_2 ,    snake_case_			: int=7 ,    snake_case_			: Any=True ,    snake_case_			: Any=True ,    snake_case_			: Optional[int]=True ,    snake_case_			: Optional[int]=9_9 ,    snake_case_			: Optional[int]=3_2 ,    snake_case_			: Tuple=3_2 ,    snake_case_			: Any=2 ,    snake_case_			: Optional[Any]=4 ,    snake_case_			: Tuple=3_7 ,    snake_case_			: int=0.1 ,    snake_case_			: List[str]=0.1 ,    snake_case_			: List[Any]=5_1_2 ,    snake_case_			: List[str]=0.02 ,    snake_case_			: str=0 ,    snake_case_			: Union[str, Any]=None ,    ):
    __a			:  List[str]		    =  parent
    __a			:  List[str]		    =  batch_size
    __a			:  Union[str, Any]		    =  seq_length
    __a			:  Any		    =  is_training
    __a			:  Any		    =  use_input_mask
    __a			:  Union[str, Any]		    =  use_labels
    __a			:  Union[str, Any]		    =  vocab_size
    __a			:  Optional[int]		    =  hidden_size
    __a			:  Union[str, Any]		    =  projection_dim
    __a			:  List[str]		    =  num_hidden_layers
    __a			:  Optional[int]		    =  num_attention_heads
    __a			:  Union[str, Any]		    =  intermediate_size
    __a			:  List[Any]		    =  dropout
    __a			:  Dict		    =  attention_dropout
    __a			:  Optional[int]		    =  max_position_embeddings
    __a			:  Any		    =  initializer_range
    __a			:  int		    =  scope
    __a			:  Optional[Any]		    =  bos_token_id
   def 				lowerCAmelCase      (self			: Tuple       ):
    __a			:  Optional[int]		    =  ids_tensor([self.batch_size, self.seq_length] ,    self.vocab_size       )

    __a			:  Dict		    =  None
    if self.use_input_mask:
     __a			:  Tuple		    =  random_attention_mask([self.batch_size, self.seq_length]       )

    if input_mask is not None:
     __a			:  int		    =  input_mask.numpy()
     __a			:  int		    =  input_mask.shape
     __a			:  Any		    =  np.random.randint(1 ,    seq_length - 1 ,    size=(batch_size,)       )
     for batch_idx, start_index in enumerate(__UpperCAmelCase       ):
      __a			:  Union[str, Any]		    =  1
      __a			:  str		    =  0

    __a			:  Tuple		    =  self.get_config()

    return config, input_ids, tf.convert_to_tensor(__UpperCAmelCase       )
   def 				lowerCAmelCase      (self			: int       ):
    return BlipTextConfig(
        vocab_size=self.vocab_size ,    hidden_size=self.hidden_size ,    projection_dim=self.projection_dim ,    num_hidden_layers=self.num_hidden_layers ,    num_attention_heads=self.num_attention_heads ,    intermediate_size=self.intermediate_size ,    dropout=self.dropout ,    attention_dropout=self.attention_dropout ,    max_position_embeddings=self.max_position_embeddings ,    initializer_range=self.initializer_range ,    bos_token_id=self.bos_token_id ,    )
   def 				lowerCAmelCase      (self			: List[str] ,    snake_case_			: Optional[int] ,    snake_case_			: Any ,    snake_case_			: Union[str, Any]       ):
    __a			:  Any		    =  TFBlipTextModel(config=__UpperCAmelCase       )
    __a			:  Tuple		    =  model(__UpperCAmelCase ,    attention_mask=__UpperCAmelCase ,    training=__UpperCAmelCase       )
    __a			:  int		    =  model(__UpperCAmelCase ,    training=__UpperCAmelCase       )
    self.parent.assertEqual(result.last_hidden_state.shape ,    (self.batch_size, self.seq_length, self.hidden_size)       )
    self.parent.assertEqual(result.pooler_output.shape ,    (self.batch_size, self.hidden_size)       )







   def 				lowerCAmelCase      (self			: Optional[Any]       ):
    __a			:  Union[str, Any]		    =  self.prepare_config_and_inputs()
    __a			:  Dict		    =  config_and_inputs
    __a			:  Optional[Any]		    =  {"""input_ids""": input_ids, """attention_mask""": input_mask}
    return config, inputs_dict





@require_tf
class 		UpperCamelCase__  (	__SCREAMING_SNAKE_CASE   ,unittest.TestCase   ):
   _SCREAMING_SNAKE_CASE				:							Optional[Any]     	=				(TFBlipTextModel,) if is_tf_available() else ()
   _SCREAMING_SNAKE_CASE				:							List[Any]     	=				False
   _SCREAMING_SNAKE_CASE				:							Any     	=				False
   _SCREAMING_SNAKE_CASE				:							Union[str, Any]     	=				False
   def 				lowerCAmelCase      (self			: Dict       ):
    __a			:  Optional[Any]		    =  BlipTextModelTester(self       )
    __a			:  Any		    =  ConfigTester(self ,    config_class=__UpperCAmelCase ,    hidden_size=3_7       )
   def 				lowerCAmelCase      (self			: List[str]       ):
    self.config_tester.run_common_tests()
   def 				lowerCAmelCase      (self			: int       ):
    __a			:  Tuple		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*__UpperCAmelCase       )
   def 				lowerCAmelCase      (self			: str       ):
    pass
   def 				lowerCAmelCase      (self			: str       ):
    pass
   @unittest.skip(reason='''Blip does not use inputs_embeds'''       )
   def 				lowerCAmelCase      (self			: Any       ):
    pass
   @unittest.skip(reason='''BlipTextModel has no base class and is not available in MODEL_MAPPING'''       )
   def 				lowerCAmelCase      (self			: Optional[Any]       ):
    pass
   @unittest.skip(reason='''BlipTextModel has no base class and is not available in MODEL_MAPPING'''       )
   def 				lowerCAmelCase      (self			: Any       ):
    pass
   @slow
   def 				lowerCAmelCase      (self			: List[Any]       ):
    for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     __a			:  List[str]		    =  TFBlipTextModel.from_pretrained(__UpperCAmelCase       )
     self.assertIsNotNone(__UpperCAmelCase       )







   def 				lowerCAmelCase      (self			: List[str] ,    snake_case_			: Any=True       ):
    super().test_pt_tf_model_equivalence(allow_missing_keys=__UpperCAmelCase       )


def        __UpperCamelCase					(    lowerCAmelCase__							:    int = 1_0_0_0  ):
 __a			:  int		    =  -1
 __a			:  Any		    =  0
 for a in range(1  ,       n // 3  ):
  # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c
  __a			:  List[Any]		    =  (n * n - 2 * a * n) // (2 * n - 2 * a)
  __a			:  Union[str, Any]		    =  n - a - b
  if c * c == (a * a + b * b):
   __a			:  Union[str, Any]		    =  a * b * c
   if candidate >= product:
    __a			:  List[Any]		    =  candidate
 return product


if __name__ == "__main__":
      print(F"""{solution() = }""")
