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






       def __init__(      self				,     UpperCamelCase_				,     UpperCamelCase_=12				,     UpperCamelCase_=7				,     UpperCamelCase_=True				,     UpperCamelCase_=True				,     UpperCamelCase_=True				,     UpperCamelCase_=99				,     UpperCamelCase_=32				,     UpperCamelCase_=32				,     UpperCamelCase_=2				,     UpperCamelCase_=4				,     UpperCamelCase_=37				,     UpperCamelCase_=0.1				,     UpperCamelCase_=0.1				,     UpperCamelCase_=5_12				,     UpperCamelCase_=0.0_2				,     UpperCamelCase_=0				,     UpperCamelCase_=None				,     ):
              __UpperCAmelCase  :				str       				=		parent
              __UpperCAmelCase  :				int       				=		batch_size
              __UpperCAmelCase  :				Dict       				=		seq_length
              __UpperCAmelCase  :				Dict       				=		is_training
              __UpperCAmelCase  :				Optional[Any]       				=		use_input_mask
              __UpperCAmelCase  :				Dict       				=		use_labels
              __UpperCAmelCase  :				int       				=		vocab_size
              __UpperCAmelCase  :				int       				=		hidden_size
              __UpperCAmelCase  :				Optional[Any]       				=		projection_dim
              __UpperCAmelCase  :				Optional[Any]       				=		num_hidden_layers
              __UpperCAmelCase  :				List[Any]       				=		num_attention_heads
              __UpperCAmelCase  :				Tuple       				=		intermediate_size
              __UpperCAmelCase  :				int       				=		dropout
              __UpperCAmelCase  :				Union[str, Any]       				=		attention_dropout
              __UpperCAmelCase  :				Optional[Any]       				=		max_position_embeddings
              __UpperCAmelCase  :				Union[str, Any]       				=		initializer_range
              __UpperCAmelCase  :				Optional[int]       				=		scope
              __UpperCAmelCase  :				Union[str, Any]       				=		bos_token_id






       def 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Union[str, Any]       				=		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  :				int       				=		input_mask.numpy()
                     __UpperCAmelCase				, __UpperCAmelCase  :				Dict       				=		input_mask.shape
                     __UpperCAmelCase  :				Optional[Any]       				=		np.random.randint(1				,     seq_length - 1				,     size=(batch_size,)      )
                     for batch_idx, start_index in enumerate(_SCREAMING_SNAKE_CASE      ):
                            __UpperCAmelCase  :				Union[str, Any]       				=		1
                            __UpperCAmelCase  :				List[Any]       				=		0

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

              return config, input_ids, tf.convert_to_tensor(_SCREAMING_SNAKE_CASE      )






       def 			_snake_case						(      self      ):
              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				,     UpperCamelCase_				,     UpperCamelCase_				,     UpperCamelCase_      ):
              __UpperCAmelCase  :				Union[str, Any]       				=		TFBlipTextModel(config=_SCREAMING_SNAKE_CASE      )
              __UpperCAmelCase  :				str       				=		model(_SCREAMING_SNAKE_CASE				,     attention_mask=_SCREAMING_SNAKE_CASE				,     training=_SCREAMING_SNAKE_CASE      )
              __UpperCAmelCase  :				str       				=		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 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Any       				=		self.prepare_config_and_inputs()
              __UpperCAmelCase				, __UpperCAmelCase				, __UpperCAmelCase  :				Union[str, Any]       				=		config_and_inputs
              __UpperCAmelCase  :				str       				=		{"input_ids": input_ids, "attention_mask": input_mask}
              return config, inputs_dict






@require_tf
class 		__A       (lowerCAmelCase__ ,					unittest.TestCase   ):
       snake_case       :List[str]				    =					(TFBlipTextModel,) if is_tf_available() else ()
       snake_case       :str				    =					False
       snake_case       :Tuple				    =					False
       snake_case       :Optional[Any]				    =					False






       def 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Dict       				=		BlipTextModelTester(self      )
              __UpperCAmelCase  :				Optional[Any]       				=		ConfigTester(self				,     config_class=_SCREAMING_SNAKE_CASE				,     hidden_size=37      )






       def 			_snake_case						(      self      ):
              self.config_tester.run_common_tests()






       def 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Dict       				=		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE      )






       def 			_snake_case						(      self      ):
              pass






       def 			_snake_case						(      self      ):
              pass






       @unittest.skip(reason="Blip does not use inputs_embeds"      )
       def 			_snake_case						(      self      ):
              pass






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






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






       @slow
       def 			_snake_case						(      self      ):
              for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                     __UpperCAmelCase  :				Optional[int]       				=		TFBlipTextModel.from_pretrained(_SCREAMING_SNAKE_CASE      )
                     self.assertIsNotNone(_SCREAMING_SNAKE_CASE      )







       def 			_snake_case						(      self				,     UpperCamelCase_=True      ):
              super().test_pt_tf_model_equivalence(allow_missing_keys=_SCREAMING_SNAKE_CASE      )



'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


_a   :	Any 							=   logging.get_logger(__name__)

_a   :	int 							=   {
    "facebook/s2t-wav2vec2-large-en-de": (
        "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json"
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}






class 		__A       (__magic_name__   ):
       snake_case       :Optional[int]				    =					"speech_to_text_2"
       snake_case       :List[Any]				    =					["past_key_values"]
       snake_case       :str				    =					{"num_attention_heads": "decoder_attention_heads", "hidden_size": "d_model"}






       def __init__(      self				,     UpperCamelCase_=1_00_00				,     UpperCamelCase_=6				,     UpperCamelCase_=20_48				,     UpperCamelCase_=4				,     UpperCamelCase_=0.0				,     UpperCamelCase_=True				,     UpperCamelCase_="relu"				,     UpperCamelCase_=2_56				,     UpperCamelCase_=0.1				,     UpperCamelCase_=0.0				,     UpperCamelCase_=0.0				,     UpperCamelCase_=0.0_2				,     UpperCamelCase_=2				,     UpperCamelCase_=True				,     UpperCamelCase_=1				,     UpperCamelCase_=0				,     UpperCamelCase_=2				,     UpperCamelCase_=10_24				,     **UpperCamelCase_				,     ):
              __UpperCAmelCase  :				Any       				=		vocab_size
              __UpperCAmelCase  :				Optional[int]       				=		d_model
              __UpperCAmelCase  :				Tuple       				=		decoder_ffn_dim
              __UpperCAmelCase  :				List[str]       				=		decoder_layers
              __UpperCAmelCase  :				str       				=		decoder_attention_heads
              __UpperCAmelCase  :				Dict       				=		dropout
              __UpperCAmelCase  :				Optional[Any]       				=		attention_dropout
              __UpperCAmelCase  :				int       				=		activation_dropout
              __UpperCAmelCase  :				Dict       				=		activation_function
              __UpperCAmelCase  :				Tuple       				=		init_std
              __UpperCAmelCase  :				Any       				=		decoder_layerdrop
              __UpperCAmelCase  :				str       				=		use_cache
              __UpperCAmelCase  :				int       				=		decoder_layers
              __UpperCAmelCase  :				Any       				=		scale_embedding  # scale factor will be sqrt(d_model) if True
              __UpperCAmelCase  :				Union[str, Any]       				=		max_target_positions

              super().__init__(
                  pad_token_id=UpperCamelCase_				,     bos_token_id=UpperCamelCase_				,     eos_token_id=UpperCamelCase_				,     decoder_start_token_id=UpperCamelCase_				,     **UpperCamelCase_				,     )






