

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







       def __init__(				self      :			int    ,   __lowercase      :			List[Any]    ,   __lowercase      :			Tuple=12    ,   __lowercase      :			Union[str, Any]=7    ,   __lowercase      :			List[str]=True    ,   __lowercase      :			int=True    ,   __lowercase      :			Tuple=True    ,   __lowercase      :			Dict=99    ,   __lowercase      :			Any=32    ,   __lowercase      :			List[str]=32    ,   __lowercase      :			Optional[int]=2    ,   __lowercase      :			List[str]=4    ,   __lowercase      :			int=37    ,   __lowercase      :			Tuple=0.1    ,   __lowercase      :			Optional[int]=0.1    ,   __lowercase      :			Optional[int]=512    ,   __lowercase      :			Optional[int]=0.0_2    ,   __lowercase      :			Optional[Any]=0    ,   __lowercase      :			Any=None    ,   ):







            """simple docstring"""







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







       def       snake_case (				self      :			str   ):







            """simple docstring"""







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

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

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

            __lowercase      		=self.get_config()

            return config, input_ids, tf.convert_to_tensor(__lowercase   )







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







            """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       snake_case (				self      :			List[str]    ,   __lowercase      :			str    ,   __lowercase      :			Union[str, Any]    ,   __lowercase      :			List[Any]   ):







            """simple docstring"""







            __lowercase      		=TFBlipTextModel(config=__lowercase   )
            __lowercase      		=model(__lowercase    ,   attention_mask=__lowercase    ,   training=__lowercase   )
            __lowercase      		=model(__lowercase    ,   training=__lowercase   )
            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       snake_case (				self      :			Union[str, Any]   ):







            """simple docstring"""







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






@require_tf
class 	lowerCAmelCase  (   A ,      unittest.TestCase ):
       lowerCAmelCase_												=			(TFBlipTextModel,) if is_tf_available() else ()
       lowerCAmelCase_												=			False
       lowerCAmelCase_												=			False
       lowerCAmelCase_												=			False







       def       snake_case (				self      :			Dict   ):







            """simple docstring"""







            __lowercase      		=BlipTextModelTester(self   )
            __lowercase      		=ConfigTester(self    ,   config_class=__lowercase    ,   hidden_size=37   )







       def       snake_case (				self      :			List[str]   ):







            """simple docstring"""







            self.config_tester.run_common_tests()







       def       snake_case (				self      :			Optional[Any]   ):







            """simple docstring"""







            __lowercase      		=self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_model(*__lowercase   )







       def       snake_case (				self      :			Optional[int]   ):







            """simple docstring"""







            pass







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







            """simple docstring"""







            pass







       @unittest.skip(reason='Blip does not use inputs_embeds'   )
       def       snake_case (				self      :			int   ):







            """simple docstring"""







            pass







       @unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'   )
       def       snake_case (				self      :			Any   ):







            """simple docstring"""







            pass







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







            """simple docstring"""







            pass







       @slow
       def       snake_case (				self      :			List[Any]   ):







            """simple docstring"""







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







       def       snake_case (				self      :			List[str]    ,   __lowercase      :			Optional[int]=True   ):







            """simple docstring"""







            super().test_pt_tf_model_equivalence(allow_missing_keys=__lowercase   )





'''simple docstring'''

from __future__ import annotations

def 					__UpperCamelCase				(						lowercase__    :	float,       lowercase__    :	float,       lowercase__    :	float			):






     '''simple docstring'''





     if (voltage, current, resistance).count(0			) != 1:
          raise ValueError('One and only one argument must be 0'			)
     if resistance < 0:
          raise ValueError('Resistance cannot be negative'			)
     if voltage == 0:
          return {"voltage": float(current * resistance			)}
     elif current == 0:
          return {"current": voltage / resistance}
     elif resistance == 0:
          return {"resistance": voltage / current}
     else:
          raise ValueError('Exactly one argument must be 0'			)


if __name__ == "__main__":
       import doctest

       doctest.testmod()


