'''simple docstring'''







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





  """simple docstring"""



  def __init__(					self     :							List[Any]				,							SCREAMING_SNAKE_CASE__     :							Optional[int]				,							SCREAMING_SNAKE_CASE__     :							List[str]=1_2				,							SCREAMING_SNAKE_CASE__     :							List[Any]=7				,							SCREAMING_SNAKE_CASE__     :							Dict=True				,							SCREAMING_SNAKE_CASE__     :							str=True				,							SCREAMING_SNAKE_CASE__     :							Union[str, Any]=True				,							SCREAMING_SNAKE_CASE__     :							Optional[int]=9_9				,							SCREAMING_SNAKE_CASE__     :							str=3_2				,							SCREAMING_SNAKE_CASE__     :							List[Any]=3_2				,							SCREAMING_SNAKE_CASE__     :							Optional[Any]=2				,							SCREAMING_SNAKE_CASE__     :							Any=4				,							SCREAMING_SNAKE_CASE__     :							List[str]=3_7				,							SCREAMING_SNAKE_CASE__     :							List[Any]=0.1				,							SCREAMING_SNAKE_CASE__     :							Any=0.1				,							SCREAMING_SNAKE_CASE__     :							str=5_1_2				,							SCREAMING_SNAKE_CASE__     :							Optional[int]=0.0_2				,							SCREAMING_SNAKE_CASE__     :							Tuple=0				,							SCREAMING_SNAKE_CASE__     :							Dict=None				,							):





       '''simple docstring'''

       __a       =   parent
       __a       =   batch_size
       __a       =   seq_length
       __a       =   is_training
       __a       =   use_input_mask
       __a       =   use_labels
       __a       =   vocab_size
       __a       =   hidden_size
       __a       =   projection_dim
       __a       =   num_hidden_layers
       __a       =   num_attention_heads
       __a       =   intermediate_size
       __a       =   dropout
       __a       =   attention_dropout
       __a       =   max_position_embeddings
       __a       =   initializer_range
       __a       =   scope
       __a       =   bos_token_id

  def __a						(					self     :							Optional[Any]						):





       '''simple docstring'''

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

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

       if input_mask is not None:
            __a       =   input_mask.numpy()
            __a       =   input_mask.shape
            __a       =   np.random.randint(1				,							seq_length - 1				,							size=(batch_size,)						)
            for batch_idx, start_index in enumerate(SCREAMING_SNAKE_CASE__						):
                 __a       =   1
                 __a       =   0

       __a       =   self.get_config()

       return config, input_ids, tf.convert_to_tensor(SCREAMING_SNAKE_CASE__						)

  def __a						(					self     :							str						):





       '''simple docstring'''

       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 __a						(					self     :							List[str]				,							SCREAMING_SNAKE_CASE__     :							str				,							SCREAMING_SNAKE_CASE__     :							Dict				,							SCREAMING_SNAKE_CASE__     :							int						):





       '''simple docstring'''

       __a       =   TFBlipTextModel(config=SCREAMING_SNAKE_CASE__						)
       __a       =   model(SCREAMING_SNAKE_CASE__				,							attention_mask=SCREAMING_SNAKE_CASE__				,							training=SCREAMING_SNAKE_CASE__						)
       __a       =   model(SCREAMING_SNAKE_CASE__				,							training=SCREAMING_SNAKE_CASE__						)
       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 __a						(					self     :							Optional[Any]						):





       '''simple docstring'''

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


@require_tf
class  lowerCAmelCase_						(       snake_case__		,    unittest.TestCase      ):





  """simple docstring"""



  a_       :List[Any]												=(TFBlipTextModel,) if is_tf_available() else ()
  a_       :Tuple												=False
  a_       :List[str]												=False
  a_       :Union[str, Any]												=False

  def __a						(					self     :							Tuple						):





       '''simple docstring'''

       __a       =   BlipTextModelTester(self						)
       __a       =   ConfigTester(self				,							config_class=SCREAMING_SNAKE_CASE__				,							hidden_size=3_7						)

  def __a						(					self     :							str						):





       '''simple docstring'''

       self.config_tester.run_common_tests()

  def __a						(					self     :							Optional[int]						):





       '''simple docstring'''

       __a       =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__						)

  def __a						(					self     :							Union[str, Any]						):





       '''simple docstring'''

       pass

  def __a						(					self     :							str						):





       '''simple docstring'''

       pass

  @unittest.skip(reason="""Blip does not use inputs_embeds"""						)
  def __a						(					self     :							Optional[int]						):





       '''simple docstring'''

       pass

  @unittest.skip(reason="""BlipTextModel has no base class and is not available in MODEL_MAPPING"""						)
  def __a						(					self     :							List[Any]						):





       '''simple docstring'''

       pass

  @unittest.skip(reason="""BlipTextModel has no base class and is not available in MODEL_MAPPING"""						)
  def __a						(					self     :							Dict						):





       '''simple docstring'''

       pass

  @slow
  def __a						(					self     :							Dict						):





       '''simple docstring'''

       for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            __a       =   TFBlipTextModel.from_pretrained(SCREAMING_SNAKE_CASE__						)
            self.assertIsNotNone(SCREAMING_SNAKE_CASE__						)


  def __a						(					self     :							Union[str, Any]				,							SCREAMING_SNAKE_CASE__     :							Any=True						):





       '''simple docstring'''

       super().test_pt_tf_model_equivalence(allow_missing_keys=SCREAMING_SNAKE_CASE__						)










'''simple docstring'''







from __future__ import annotations




def        __lowercase						(      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  )				->					tuple[str, float]:
     """simple docstring"""




     if (stress, tangential_force, area).count(0		) != 1:
          raise ValueError("""You cannot supply more or less than 2 values"""		)
     elif stress < 0:
          raise ValueError("""Stress cannot be negative"""		)
     elif tangential_force < 0:
          raise ValueError("""Tangential Force cannot be negative"""		)
     elif area < 0:
          raise ValueError("""Area cannot be negative"""		)
     elif stress == 0:
          return (
              "stress",
              tangential_force / area,
          )
     elif tangential_force == 0:
          return (
              "tangential_force",
              stress * area,
          )
     else:
          return (
              "area",
              tangential_force / stress,
          )


if __name__ == "__main__":
 import doctest

 doctest.testmod()






