





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

   '''simple docstring'''


   def __init__(    self,		__magic_name__,		__magic_name__=12,		__magic_name__=7,		__magic_name__=True,		__magic_name__=True,		__magic_name__=True,		__magic_name__=99,		__magic_name__=32,		__magic_name__=32,		__magic_name__=2,		__magic_name__=4,		__magic_name__=37,		__magic_name__=0.1,		__magic_name__=0.1,		__magic_name__=512,		__magic_name__=0.02,		__magic_name__=0,		__magic_name__=None,		) ->      Optional[int]:






       """simple docstring"""
       UpperCamelCase__							:				Any          =      parent
       UpperCamelCase__							:				List[str]          =      batch_size
       UpperCamelCase__							:				int          =      seq_length
       UpperCamelCase__							:				str          =      is_training
       UpperCamelCase__							:				Any          =      use_input_mask
       UpperCamelCase__							:				Optional[int]          =      use_labels
       UpperCamelCase__							:				Optional[Any]          =      vocab_size
       UpperCamelCase__							:				Any          =      hidden_size
       UpperCamelCase__							:				Union[str, Any]          =      projection_dim
       UpperCamelCase__							:				str          =      num_hidden_layers
       UpperCamelCase__							:				int          =      num_attention_heads
       UpperCamelCase__							:				Tuple          =      intermediate_size
       UpperCamelCase__							:				Tuple          =      dropout
       UpperCamelCase__							:				Optional[int]          =      attention_dropout
       UpperCamelCase__							:				List[str]          =      max_position_embeddings
       UpperCamelCase__							:				str          =      initializer_range
       UpperCamelCase__							:				str          =      scope
       UpperCamelCase__							:				Union[str, Any]          =      bos_token_id




   def       UpperCamelCase__  (    self							) ->      str:






       """simple docstring"""
       UpperCamelCase__							:				Tuple          =      ids_tensor([self.batch_size, self.seq_length],		self.vocab_size							)

       UpperCamelCase__							:				Optional[int]          =      None
       if self.use_input_mask:
           UpperCamelCase__							:				Union[str, Any]          =      random_attention_mask([self.batch_size, self.seq_length]							)

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

       UpperCamelCase__							:				List[Any]          =      self.get_config()

       return config, input_ids, tf.convert_to_tensor(__magic_name__							)




   def       UpperCamelCase__  (    self							) ->      Tuple:






       """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       UpperCamelCase__  (    self,		__magic_name__,		__magic_name__,		__magic_name__							) ->      int:






       """simple docstring"""
       UpperCamelCase__							:				Optional[int]          =      TFBlipTextModel(config=__magic_name__							)
       UpperCamelCase__							:				Optional[Any]          =      model(__magic_name__,		attention_mask=__magic_name__,		training=__magic_name__							)
       UpperCamelCase__							:				int          =      model(__magic_name__,		training=__magic_name__							)
       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       UpperCamelCase__  (    self							) ->      List[Any]:






       """simple docstring"""
       UpperCamelCase__							:				List[Any]          =      self.prepare_config_and_inputs()
       UpperCamelCase__   ,UpperCamelCase__   ,UpperCamelCase__							:				Optional[int]          =      config_and_inputs
       UpperCamelCase__							:				Tuple          =      {'''input_ids''': input_ids, '''attention_mask''': input_mask}
       return config, inputs_dict






@require_tf
class     lowercase__       (	__lowerCamelCase			,				unittest.TestCase				):

   '''simple docstring'''


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




   def       UpperCamelCase__  (    self							) ->      int:






       """simple docstring"""
       UpperCamelCase__							:				List[Any]          =      BlipTextModelTester(self							)
       UpperCamelCase__							:				List[Any]          =      ConfigTester(self,		config_class=__magic_name__,		hidden_size=37							)




   def       UpperCamelCase__  (    self							) ->      Tuple:






       """simple docstring"""
       self.config_tester.run_common_tests()




   def       UpperCamelCase__  (    self							) ->      Dict:






       """simple docstring"""
       UpperCamelCase__							:				Dict          =      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*__magic_name__							)




   def       UpperCamelCase__  (    self							) ->      Optional[int]:






       """simple docstring"""
       pass




   def       UpperCamelCase__  (    self							) ->      Optional[int]:






       """simple docstring"""
       pass




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






       """simple docstring"""
       pass




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






       """simple docstring"""
       pass




   @unittest.skip(reason='''BlipTextModel has no base class and is not available in MODEL_MAPPING'''							)
   def       UpperCamelCase__  (    self							) ->      Union[str, Any]:






       """simple docstring"""
       pass




   @slow
   def       UpperCamelCase__  (    self							) ->      Optional[Any]:






       """simple docstring"""
       for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           UpperCamelCase__							:				Dict          =      TFBlipTextModel.from_pretrained(__magic_name__							)
           self.assertIsNotNone(__magic_name__							)




   def       UpperCamelCase__  (    self,		__magic_name__=True							) ->      Union[str, Any]:






       """simple docstring"""
       super().test_pt_tf_model_equivalence(allow_missing_keys=__magic_name__							)








from __future__ import annotations




def 		lowerCAmelCase_    (  __UpperCAmelCase:			list[int]		,   __UpperCAmelCase:			int      )      ->	list[int]:
    UpperCamelCase__							:				Optional[int]          =      0
    UpperCamelCase__							:				Tuple          =      len(__UpperCAmelCase      ) - 1

    while i < j:
        if nums[i] + nums[j] == target:
            return [i, j]
        elif nums[i] + nums[j] < target:
            UpperCamelCase__							:				Tuple          =      i + 1
        else:
            UpperCamelCase__							:				str          =      j - 1

    return []


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  print(F'''{two_pointer([2, 7, 11, 15], 9) = }''')

