






"""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 ,				snake_case_ ,				snake_case_=12 ,				snake_case_=7 ,				snake_case_=True ,				snake_case_=True ,				snake_case_=True ,				snake_case_=99 ,				snake_case_=32 ,				snake_case_=32 ,				snake_case_=2 ,				snake_case_=4 ,				snake_case_=37 ,				snake_case_=0.1 ,				snake_case_=0.1 ,				snake_case_=512 ,				snake_case_=0.02 ,				snake_case_=0 ,				snake_case_=None ,				)		->       Dict:
        UpperCamelCase__         =    parent
        UpperCamelCase__         =    batch_size
        UpperCamelCase__         =    seq_length
        UpperCamelCase__         =    is_training
        UpperCamelCase__         =    use_input_mask
        UpperCamelCase__         =    use_labels
        UpperCamelCase__         =    vocab_size
        UpperCamelCase__         =    hidden_size
        UpperCamelCase__         =    projection_dim
        UpperCamelCase__         =    num_hidden_layers
        UpperCamelCase__         =    num_attention_heads
        UpperCamelCase__         =    intermediate_size
        UpperCamelCase__         =    dropout
        UpperCamelCase__         =    attention_dropout
        UpperCamelCase__         =    max_position_embeddings
        UpperCamelCase__         =    initializer_range
        UpperCamelCase__         =    scope
        UpperCamelCase__         =    bos_token_id

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Any:
        UpperCamelCase__         =    ids_tensor([self.batch_size, self.seq_length] ,				self.vocab_size      )

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

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

        UpperCamelCase__         =    self.get_config()

        return config, input_ids, tf.convert_to_tensor(snake_case_      )

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Any:
        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 						SCREAMING_SNAKE_CASE__ (					self ,				snake_case_ ,				snake_case_ ,				snake_case_      )		->       Tuple:
        UpperCamelCase__         =    TFBlipTextModel(config=snake_case_      )
        UpperCamelCase__         =    model(snake_case_ ,				attention_mask=snake_case_ ,				training=snake_case_      )
        UpperCamelCase__         =    model(snake_case_ ,				training=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 						SCREAMING_SNAKE_CASE__ (					self      )		->       Dict:
        UpperCamelCase__         =    self.prepare_config_and_inputs()
        UpperCamelCase__       ,						UpperCamelCase__       ,						UpperCamelCase__         =    config_and_inputs
        UpperCamelCase__         =    {'input_ids': input_ids, 'attention_mask': input_mask}
        return config, inputs_dict







@require_tf
class    __lowerCamelCase    (  _a							,	unittest.TestCase  ):
   a      :				List[str] 						=(TFBlipTextModel,) if is_tf_available() else ()
   a      :				int 						=False
   a      :				Any 						=False
   a      :				Optional[Any] 						=False

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Union[str, Any]:
        UpperCamelCase__         =    BlipTextModelTester(self      )
        UpperCamelCase__         =    ConfigTester(self ,				config_class=snake_case_ ,				hidden_size=37      )

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Union[str, Any]:
        self.config_tester.run_common_tests()

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       List[Any]:
        UpperCamelCase__         =    self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*snake_case_      )

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Optional[int]:
        pass

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Union[str, Any]:
        pass

   @unittest.skip(reason='Blip does not use inputs_embeds'      )
   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Union[str, Any]:
        pass

   @unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'      )
   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       int:
        pass

   @unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING'      )
   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       int:
        pass

   @slow
   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Any:
        for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             UpperCamelCase__         =    TFBlipTextModel.from_pretrained(snake_case_      )
             self.assertIsNotNone(snake_case_      )







   def 						SCREAMING_SNAKE_CASE__ (					self ,				snake_case_=True      )		->       Tuple:
        super().test_pt_tf_model_equivalence(allow_missing_keys=snake_case_      )












"""simple docstring"""





from collections import defaultdict
from math import ceil, sqrt







def   lowerCAmelCase_( SCREAMING_SNAKE_CASE = 1_00_00_00 ,	SCREAMING_SNAKE_CASE = 10					)					->	int:
    """simple docstring"""

    UpperCamelCase__         =    defaultdict(SCREAMING_SNAKE_CASE					)

    for outer_width in range(3 ,	(t_limit // 4) + 2					):
        if outer_width * outer_width > t_limit:
            UpperCamelCase__         =    max(
                ceil(sqrt(outer_width * outer_width - t_limit					)					) ,	1					)
        else:
            UpperCamelCase__         =    1

        hole_width_lower_bound += (outer_width - hole_width_lower_bound) % 2

        for hole_width in range(SCREAMING_SNAKE_CASE ,	outer_width - 1 ,	2					):
            count[outer_width * outer_width - hole_width * hole_width] += 1

    return sum(1 for n in count.values() if 1 <= n <= 10					)


if __name__ == "__main__":
  print(F"""{solution() = }""")




