
import inspect
import unittest

import numpy as np

from transformers import ViTConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor


if is_flax_available():
     import jax

     from transformers.models.vit.modeling_flax_vit import FlaxViTForImageClassification, FlaxViTModel



class       _snake_case   (	unittest.TestCase							):


 def __init__(					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_=13					,  SCREAMING_SNAKE_CASE_=30					,  SCREAMING_SNAKE_CASE_=2					,  SCREAMING_SNAKE_CASE_=3					,  SCREAMING_SNAKE_CASE_=True					,  SCREAMING_SNAKE_CASE_=True					,  SCREAMING_SNAKE_CASE_=32					,  SCREAMING_SNAKE_CASE_=5					,  SCREAMING_SNAKE_CASE_=4					,  SCREAMING_SNAKE_CASE_=37					,  SCREAMING_SNAKE_CASE_="gelu"					,  SCREAMING_SNAKE_CASE_=0.1					,  SCREAMING_SNAKE_CASE_=0.1					,  SCREAMING_SNAKE_CASE_=10					,  SCREAMING_SNAKE_CASE_=0.0_2					,  ):


   '''simple docstring'''




   lowercase__  :   int    		=      parent
   lowercase__  :   List[str]    		=      batch_size
   lowercase__  :   Dict    		=      image_size
   lowercase__  :   Union[str, Any]    		=      patch_size
   lowercase__  :   Optional[int]    		=      num_channels
   lowercase__  :   Dict    		=      is_training
   lowercase__  :   List[str]    		=      use_labels
   lowercase__  :   int    		=      hidden_size
   lowercase__  :   str    		=      num_hidden_layers
   lowercase__  :   Union[str, Any]    		=      num_attention_heads
   lowercase__  :   Union[str, Any]    		=      intermediate_size
   lowercase__  :   List[Any]    		=      hidden_act
   lowercase__  :   Tuple    		=      hidden_dropout_prob
   lowercase__  :   Tuple    		=      attention_probs_dropout_prob
   lowercase__  :   Optional[Any]    		=      type_sequence_label_size
   lowercase__  :   Tuple    		=      initializer_range

   # in ViT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
   lowercase__  :   int    		=      (image_size // patch_size) ** 2
   lowercase__  :   Tuple    		=      num_patches + 1


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Optional[int]    		=      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

   lowercase__  :   int    		=      ViTConfig(
       image_size=self.image_size					,  patch_size=self.patch_size					,  num_channels=self.num_channels					,  hidden_size=self.hidden_size					,  num_hidden_layers=self.num_hidden_layers					,  num_attention_heads=self.num_attention_heads					,  intermediate_size=self.intermediate_size					,  hidden_act=self.hidden_act					,  hidden_dropout_prob=self.hidden_dropout_prob					,  attention_probs_dropout_prob=self.attention_probs_dropout_prob					,  is_decoder=SCREAMING_SNAKE_CASE_					,  initializer_range=self.initializer_range					,  )

   return config, pixel_values


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   List[str]    		=      FlaxViTModel(config=SCREAMING_SNAKE_CASE_)
   lowercase__  :   Optional[Any]    		=      model(SCREAMING_SNAKE_CASE_)
   # expected sequence length = num_patches + 1 (we add 1 for the [CLS] token)
   lowercase__  :   int    		=      (self.image_size, self.image_size)
   lowercase__  :   str    		=      (self.patch_size, self.patch_size)
   lowercase__  :   str    		=      (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
   self.parent.assertEqual(result.last_hidden_state.shape					,  (self.batch_size, num_patches + 1, self.hidden_size))


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__  :   Dict    		=      self.type_sequence_label_size
   lowercase__  :   Optional[Any]    		=      FlaxViTForImageClassification(config=SCREAMING_SNAKE_CASE_)
   lowercase__  :   List[str]    		=      model(SCREAMING_SNAKE_CASE_)
   self.parent.assertEqual(result.logits.shape					,  (self.batch_size, self.type_sequence_label_size))

   # test greyscale images
   lowercase__  :   Any    		=      1
   lowercase__  :   List[str]    		=      FlaxViTForImageClassification(SCREAMING_SNAKE_CASE_)

   lowercase__  :   Optional[Any]    		=      floats_tensor([self.batch_size, 1, self.image_size, self.image_size])
   lowercase__  :   Tuple    		=      model(SCREAMING_SNAKE_CASE_)



 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Optional[int]    		=      self.prepare_config_and_inputs()
   (
       (
       lowercase__
   )		,    (
       lowercase__
   )		,    
   )  :   str    		=      config_and_inputs
   lowercase__  :   Tuple    		=      {"""pixel_values""": pixel_values}
   return config, inputs_dict



@require_flax
class       _snake_case   (	UpperCAmelCase_  ,						unittest.TestCase							):
 __lowerCAmelCase  :     Union[str, Any]        =			(FlaxViTModel, FlaxViTForImageClassification) if is_flax_available() else ()


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Dict    		=      FlaxViTModelTester(self)
   lowercase__  :   Tuple    		=      ConfigTester(self					,  config_class=SCREAMING_SNAKE_CASE_					,  has_text_modality=SCREAMING_SNAKE_CASE_					,  hidden_size=37)


 def      lowercase__     (					self):


   '''simple docstring'''




   self.config_tester.run_common_tests()


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   List[str]    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__  :   Any    		=      self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_image_classification(*SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__		,    lowercase__  :   Optional[int]    		=      self.model_tester.prepare_config_and_inputs_for_common()

   for model_class in self.all_model_classes:
     lowercase__  :   Tuple    		=      model_class(SCREAMING_SNAKE_CASE_)
     lowercase__  :   Optional[Any]    		=      inspect.signature(model.__call__)
     # signature.parameters is an OrderedDict => so arg_names order is deterministic
     lowercase__  :   Optional[Any]    		=      [*signature.parameters.keys()]

     lowercase__  :   List[str]    		=      ["""pixel_values"""]
     self.assertListEqual(arg_names[:1]					,  SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self):


   '''simple docstring'''




   lowercase__		,    lowercase__  :   Optional[int]    		=      self.model_tester.prepare_config_and_inputs_for_common()

   for model_class in self.all_model_classes:
     with self.subTest(model_class.__name__):
       lowercase__  :   List[str]    		=      self._prepare_for_class(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_)
       lowercase__  :   Any    		=      model_class(SCREAMING_SNAKE_CASE_)

       @jax.jit
       def model_jitted(SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):
         return model(pixel_values=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_)

       with self.subTest("""JIT Enabled"""):
         lowercase__  :   Tuple    		=      model_jitted(**SCREAMING_SNAKE_CASE_).to_tuple()

       with self.subTest("""JIT Disabled"""):
         with jax.disable_jit():
           lowercase__  :   Optional[Any]    		=      model_jitted(**SCREAMING_SNAKE_CASE_).to_tuple()

       self.assertEqual(len(SCREAMING_SNAKE_CASE_)					,  len(SCREAMING_SNAKE_CASE_))
       for jitted_output, output in zip(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_):
         self.assertEqual(jitted_output.shape					,  output.shape)



 @slow
 def      lowercase__     (					self):


   '''simple docstring'''




   for model_class_name in self.all_model_classes:
     lowercase__  :   int    		=      model_class_name.from_pretrained("""google/vit-base-patch16-224""")
     lowercase__  :   Optional[int]    		=      model(np.ones((1, 3, 2_24, 2_24)))
     self.assertIsNotNone(SCREAMING_SNAKE_CASE_)








import sys

lowerCamelCase__    :		List[Any]          =   (
    """73167176531330624919225119674426574742355349194934"""
    """96983520312774506326239578318016984801869478851843"""
    """85861560789112949495459501737958331952853208805511"""
    """12540698747158523863050715693290963295227443043557"""
    """66896648950445244523161731856403098711121722383113"""
    """62229893423380308135336276614282806444486645238749"""
    """30358907296290491560440772390713810515859307960866"""
    """70172427121883998797908792274921901699720888093776"""
    """65727333001053367881220235421809751254540594752243"""
    """52584907711670556013604839586446706324415722155397"""
    """53697817977846174064955149290862569321978468622482"""
    """83972241375657056057490261407972968652414535100474"""
    """82166370484403199890008895243450658541227588666881"""
    """16427171479924442928230863465674813919123162824586"""
    """17866458359124566529476545682848912883142607690042"""
    """24219022671055626321111109370544217506941658960408"""
    """07198403850962455444362981230987879927244284909188"""
    """84580156166097919133875499200524063689912560717606"""
    """05886116467109405077541002256983155200055935729725"""
    """71636269561882670428252483600823257530420752963450"""
)

def 		UpperCamelCase	(      lowercase_ = N   )		->	int:


  '''simple docstring'''






  lowercase__  :   int    		=      -sys.maxsize - 1
  for i in range(len(lowercase_   ) - 12   ):
    lowercase__  :   Optional[int]    		=      1
    for j in range(13   ):
      product *= int(n[i + j]   )
    if product > largest_product:
      lowercase__  :   int    		=      product
  return largest_product


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






