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


			'''simple docstring'''






			def __init__(  self			,       __lowerCAmelCase			,       __lowerCAmelCase=12			,       __lowerCAmelCase=7			,       __lowerCAmelCase=True			,       __lowerCAmelCase=True			,       __lowerCAmelCase=True			,       __lowerCAmelCase=99			,       __lowerCAmelCase=32			,       __lowerCAmelCase=32			,       __lowerCAmelCase=2			,       __lowerCAmelCase=4			,       __lowerCAmelCase=37			,       __lowerCAmelCase=0.1			,       __lowerCAmelCase=0.1			,       __lowerCAmelCase=512			,       __lowerCAmelCase=0.02			,       __lowerCAmelCase=0			,       __lowerCAmelCase=None			,       ):




					"""simple docstring"""


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



			def 				a_			(  self):




					"""simple docstring"""


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

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

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

					lowerCAmelCase     =    self.get_config()

					return config, input_ids, tf.convert_to_tensor(__lowerCAmelCase)



			def 				a_			(  self):




					"""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			,       __lowerCAmelCase			,       __lowerCAmelCase			,       __lowerCAmelCase):




					"""simple docstring"""


					lowerCAmelCase     =    TFBlipTextModel(config=__lowerCAmelCase)
					lowerCAmelCase     =    model(__lowerCAmelCase			,       attention_mask=__lowerCAmelCase			,       training=__lowerCAmelCase)
					lowerCAmelCase     =    model(__lowerCAmelCase			,       training=__lowerCAmelCase)
					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):




					"""simple docstring"""


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







@require_tf
class 							a__(   lowerCAmelCase__					,		unittest.TestCase      ):


			'''simple docstring'''






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



			def 				a_			(  self):




					"""simple docstring"""


					lowerCAmelCase     =    BlipTextModelTester(self)
					lowerCAmelCase     =    ConfigTester(self			,       config_class=__lowerCAmelCase			,       hidden_size=37)



			def 				a_			(  self):




					"""simple docstring"""


					self.config_tester.run_common_tests()



			def 				a_			(  self):




					"""simple docstring"""


					lowerCAmelCase     =    self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*__lowerCAmelCase)



			def 				a_			(  self):




					"""simple docstring"""


					pass



			def 				a_			(  self):




					"""simple docstring"""


					pass



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




					"""simple docstring"""


					pass



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




					"""simple docstring"""


					pass



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




					"""simple docstring"""


					pass



			@slow
			def 				a_			(  self):




					"""simple docstring"""


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







			def 				a_			(  self			,       __lowerCAmelCase=True):




					"""simple docstring"""


					super().test_pt_tf_model_equivalence(allow_missing_keys=__lowerCAmelCase)





'''simple docstring'''




def 							snake_case__				(     _A:   int					)       ->      list[int]:

		'''simple docstring'''


		if length <= 0 or not isinstance(_A ,  _A					):
				raise ValueError("""Length must be a positive integer."""					)
		return [n * (2 * n - 1) for n in range(_A					)]


if __name__ == "__main__":
						print(hexagonal_numbers(length=5))
						print(hexagonal_numbers(length=1_0))




