




'''simple docstring'''


import inspect
import unittest
from math import floor

from transformers import CvtConfig
from transformers.file_utils import cached_property, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import CvtForImageClassification, CvtModel
  from transformers.models.cvt.modeling_cvt import CVT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
  from PIL import Image

  from transformers import AutoImageProcessor





class    __lowercase						(  __magic_name__ ):







   def 		UpperCamelCase__			(	self      )				->    Union[str, Any]:
     __a			=					self.config_class(**self.inputs_dict      )
     self.parent.assertTrue(hasattr(UpperCamelCase      ,							'embed_dim'      )      )
     self.parent.assertTrue(hasattr(UpperCamelCase      ,							'num_heads'      )      )





class    __lowercase						:







   def __init__(	self      ,							UpperCamelCase      ,							UpperCamelCase=13      ,							UpperCamelCase=64      ,							UpperCamelCase=3      ,							UpperCamelCase=[16, 48, 96]      ,							UpperCamelCase=[1, 3, 6]      ,							UpperCamelCase=[1, 2, 10]      ,							UpperCamelCase=[7, 3, 3]      ,							UpperCamelCase=[4, 2, 2]      ,							UpperCamelCase=[2, 1, 1]      ,							UpperCamelCase=[2, 2, 2]      ,							UpperCamelCase=[False, False, True]      ,							UpperCamelCase=[0.0, 0.0, 0.0]      ,							UpperCamelCase=0.02      ,							UpperCamelCase=1e-12      ,							UpperCamelCase=True      ,							UpperCamelCase=True      ,							UpperCamelCase=2      ,							)				->    Optional[int]:
     __a			=					parent
     __a			=					batch_size
     __a			=					image_size
     __a			=					patch_sizes
     __a			=					patch_stride
     __a			=					patch_padding
     __a			=					is_training
     __a			=					use_labels
     __a			=					num_labels
     __a			=					num_channels
     __a			=					embed_dim
     __a			=					num_heads
     __a			=					stride_kv
     __a			=					depth
     __a			=					cls_token
     __a			=					attention_drop_rate
     __a			=					initializer_range
     __a			=					layer_norm_eps







   def 		UpperCamelCase__			(	self      )				->    int:
     __a			=					floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]      )

     __a			=					None
     if self.use_labels:
       __a			=					ids_tensor([self.batch_size]      ,							self.num_labels      )

     __a			=					self.get_config()
     return config, pixel_values, labels







   def 		UpperCamelCase__			(	self      )				->    Any:
     return CvtConfig(
         image_size=self.image_size      ,							num_labels=self.num_labels      ,							num_channels=self.num_channels      ,							embed_dim=self.embed_dim      ,							num_heads=self.num_heads      ,							patch_sizes=self.patch_sizes      ,							patch_padding=self.patch_padding      ,							patch_stride=self.patch_stride      ,							stride_kv=self.stride_kv      ,							depth=self.depth      ,							cls_token=self.cls_token      ,							attention_drop_rate=self.attention_drop_rate      ,							initializer_range=self.initializer_range      ,							)







   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      )				->    Union[str, Any]:
     __a			=					CvtModel(config=UpperCamelCase      )
     model.to(UpperCamelCase      )
     model.eval()
     __a			=					model(UpperCamelCase      )
     __a			=					(self.image_size, self.image_size)
     __a	,       __a			=					image_size[0], image_size[1]
     for i in range(len(self.depth      )      ):
       __a			=					floor(((height + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1      )
       __a			=					floor(((width + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1      )
     self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, self.embed_dim[-1], height, width)      )







   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      )				->    str:
     __a			=					self.num_labels
     __a			=					CvtForImageClassification(UpperCamelCase      )
     model.to(UpperCamelCase      )
     model.eval()
     __a			=					model(UpperCamelCase      ,							labels=UpperCamelCase      )
     self.parent.assertEqual(result.logits.shape      ,							(self.batch_size, self.num_labels)      )







   def 		UpperCamelCase__			(	self      )				->    Tuple:
     __a			=					self.prepare_config_and_inputs()
     __a	,       __a	,       __a			=					config_and_inputs
     __a			=					{'pixel_values': pixel_values}
     return config, inputs_dict





@require_torch
class    __lowercase						(  __magic_name__       ,							__magic_name__       ,							unittest.TestCase ):
   _a							=      (CvtModel, CvtForImageClassification) if is_torch_available() else ()
   _a							=      (
       {"""feature-extraction""": CvtModel, """image-classification""": CvtForImageClassification}
       if is_torch_available()
       else {}
   )

   _a							=      False
   _a							=      False
   _a							=      False
   _a							=      False
   _a							=      False







   def 		UpperCamelCase__			(	self      )				->    Optional[int]:
     __a			=					CvtModelTester(self      )
     __a			=					ConfigTester(self      ,							config_class=UpperCamelCase      ,							has_text_modality=UpperCamelCase      ,							hidden_size=37      )







   def 		UpperCamelCase__			(	self      )				->    Any:
     self.create_and_test_config_common_properties()
     self.config_tester.create_and_test_config_to_json_string()
     self.config_tester.create_and_test_config_to_json_file()
     self.config_tester.create_and_test_config_from_and_save_pretrained()
     self.config_tester.create_and_test_config_with_num_labels()
     self.config_tester.check_config_can_be_init_without_params()
     self.config_tester.check_config_arguments_init()







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







   @unittest.skip(reason='Cvt does not output attentions'      )
   def 		UpperCamelCase__			(	self      )				->    List[Any]:
     pass







   @unittest.skip(reason='Cvt does not use inputs_embeds'      )
   def 		UpperCamelCase__			(	self      )				->    Tuple:
     pass







   @unittest.skip(reason='Cvt does not support input and output embeddings'      )
   def 		UpperCamelCase__			(	self      )				->    str:
     pass







   def 		UpperCamelCase__			(	self      )				->    List[str]:
     __a	,       __a			=					self.model_tester.prepare_config_and_inputs_for_common()

     for model_class in self.all_model_classes:
       __a			=					model_class(UpperCamelCase      )
       __a			=					inspect.signature(model.forward      )
       # signature.parameters is an OrderedDict => so arg_names order is deterministic
       __a			=					[*signature.parameters.keys()]

       __a			=					['pixel_values']
       self.assertListEqual(arg_names[:1]      ,							UpperCamelCase      )







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







   def 		UpperCamelCase__			(	self      )				->    Optional[Any]:
     def check_hidden_states_output(UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ):
       __a			=					model_class(UpperCamelCase      )
       model.to(UpperCamelCase      )
       model.eval()

       with torch.no_grad():
         __a			=					model(**self._prepare_for_class(UpperCamelCase      ,							UpperCamelCase      )      )

       __a			=					outputs.hidden_states

       __a			=					len(self.model_tester.depth      )
       self.assertEqual(len(UpperCamelCase      )      ,							UpperCamelCase      )

       # verify the first hidden states (first block)
       self.assertListEqual(
           list(hidden_states[0].shape[-3:]      )      ,							[
               self.model_tester.embed_dim[0],
               self.model_tester.image_size // 4,
               self.model_tester.image_size // 4,
           ]      ,							)

     __a	,       __a			=					self.model_tester.prepare_config_and_inputs_for_common()

     for model_class in self.all_model_classes:
       __a			=					True
       check_hidden_states_output(UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      )

       # check that output_hidden_states also work using config
       del inputs_dict["output_hidden_states"]
       __a			=					True

       check_hidden_states_output(UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      )







   def 		UpperCamelCase__			(	self      )				->    Tuple:
     __a			=					self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_image_classification(*UpperCamelCase      )







   @unittest.skip('Will be fixed soon by reducing the size of the model used for common tests.'      )
   def 		UpperCamelCase__			(	self      )				->    Tuple:
     pass







   @slow
   def 		UpperCamelCase__			(	self      )				->    int:
     for model_name in CVT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       __a			=					CvtModel.from_pretrained(UpperCamelCase      )
       self.assertIsNotNone(UpperCamelCase      )


def 						SCREAMING_SNAKE_CASE       (      ):
  __a			=					Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'			)
  return image





@require_torch
@require_vision
class    __lowercase						(  unittest.TestCase ):







   @cached_property
   def 		UpperCamelCase__			(	self      )				->    List[str]:
     return AutoImageProcessor.from_pretrained(CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]      )







   @slow
   def 		UpperCamelCase__			(	self      )				->    Tuple:
     __a			=					CvtForImageClassification.from_pretrained(CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]      ).to(UpperCamelCase      )

     __a			=					self.default_image_processor
     __a			=					prepare_img()
     __a			=					image_processor(images=UpperCamelCase      ,							return_tensors='pt'      ).to(UpperCamelCase      )

     # forward pass
     with torch.no_grad():
       __a			=					model(**UpperCamelCase      )

     # verify the logits
     __a			=					torch.Size((1, 1000)      )
     self.assertEqual(outputs.logits.shape      ,							UpperCamelCase      )

     __a			=					torch.tensor([0.9_285, 0.9_015, -0.3_150]      ).to(UpperCamelCase      )

     self.assertTrue(torch.allclose(outputs.logits[0, :3]      ,							UpperCamelCase      ,							atol=1e-4      )      )









'''simple docstring'''


import os


def 						SCREAMING_SNAKE_CASE       (      ):
  with open(os.path.dirname(a_			) + '/grid.txt'			) as f:
    __a			=					[]  # noqa: E741
    for _ in range(20			):
      l.append([int(a_			) for x in f.readline().split()]			)

    __a			=					0

    # right
    for i in range(20			):
      for j in range(17			):
        __a			=					l[i][j] * l[i][j + 1] * l[i][j + 2] * l[i][j + 3]
        if temp > maximum:
          __a			=					temp

        # down
    for i in range(17			):
      for j in range(20			):
        __a			=					l[i][j] * l[i + 1][j] * l[i + 2][j] * l[i + 3][j]
        if temp > maximum:
          __a			=					temp

        # diagonal 1
    for i in range(17			):
      for j in range(17			):
        __a			=					l[i][j] * l[i + 1][j + 1] * l[i + 2][j + 2] * l[i + 3][j + 3]
        if temp > maximum:
          __a			=					temp

        # diagonal 2
    for i in range(17			):
      for j in range(3				,					20			):
        __a			=					l[i][j] * l[i + 1][j - 1] * l[i + 2][j - 2] * l[i + 3][j - 3]
        if temp > maximum:
          __a			=					temp
    return maximum


if __name__ == "__main__":
  print(solution())



