
"""simple docstring"""
import unittest
from typing import Dict, List, Optional, Union

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import BridgeTowerImageProcessor
class       lowerCAmelCase_		(				unittest.TestCase ):



							'''simple docstring'''





							def __init__( self    ,				snake_case_    ,				snake_case_ = True    ,				snake_case_ = None    ,				snake_case_ = 32    ,				snake_case_ = True    ,				snake_case_ = 1 / 255    ,				snake_case_ = True    ,				snake_case_ = True    ,				snake_case_ = [0.48_145_466, 0.4_578_275, 0.40_821_073]    ,				snake_case_ = [0.26_862_954, 0.26_130_258, 0.27_577_711]    ,				snake_case_ = True    ,				snake_case_=7    ,				snake_case_=30    ,				snake_case_=400    ,				snake_case_=3    ,				)       ->  Optional[int]:
													__lowerCAmelCase     =  parent
													__lowerCAmelCase     =  do_resize
													__lowerCAmelCase     =  size if size is not None else {"""shortest_edge""": 288}
													__lowerCAmelCase     =  size_divisor
													__lowerCAmelCase     =  do_rescale
													__lowerCAmelCase     =  rescale_factor
													__lowerCAmelCase     =  do_normalize
													__lowerCAmelCase     =  do_center_crop
													__lowerCAmelCase     =  image_mean
													__lowerCAmelCase     =  image_std
													__lowerCAmelCase     =  do_pad
													__lowerCAmelCase     =  batch_size
													__lowerCAmelCase     =  num_channels
													__lowerCAmelCase     =  min_resolution
													__lowerCAmelCase     =  max_resolution




							def    A__						( self				)       ->  Union[str, Any]:
													return {
													    "image_mean": self.image_mean,
													    "image_std": self.image_std,
													    "do_normalize": self.do_normalize,
													    "do_resize": self.do_resize,
													    "size": self.size,
													    "size_divisor": self.size_divisor,
													}




							def    A__						( self    ,				snake_case_    ,				snake_case_=False				)       ->  Union[str, Any]:
													if not batched:
																			__lowerCAmelCase     =  self.size["""shortest_edge"""]
																			__lowerCAmelCase     =  image_inputs[0]
																			if isinstance(snake_case_    ,				Image.Image				):
																									__lowerCAmelCase   ,     __lowerCAmelCase     =  image.size
																			else:
																									__lowerCAmelCase   ,     __lowerCAmelCase     =  image.shape[1], image.shape[2]
																			__lowerCAmelCase     =  size / min(snake_case_    ,				snake_case_				)
																			if h < w:
																									__lowerCAmelCase   ,     __lowerCAmelCase     =  size, scale * w
																			else:
																									__lowerCAmelCase   ,     __lowerCAmelCase     =  scale * h, size

																			__lowerCAmelCase     =  int((1_333 / 800) * size				)
																			if max(snake_case_    ,				snake_case_				) > max_size:
																									__lowerCAmelCase     =  max_size / max(snake_case_    ,				snake_case_				)
																									__lowerCAmelCase     =  newh * scale
																									__lowerCAmelCase     =  neww * scale

																			__lowerCAmelCase   ,     __lowerCAmelCase     =  int(newh + 0.5				), int(neww + 0.5				)
																			__lowerCAmelCase   ,     __lowerCAmelCase     =  (
																			    newh // self.size_divisor * self.size_divisor,
																			    neww // self.size_divisor * self.size_divisor,
																			)

													else:
																			__lowerCAmelCase     =  []
																			for image in image_inputs:
																									__lowerCAmelCase   ,     __lowerCAmelCase     =  self.get_expected_values([image]				)
																									expected_values.append((expected_height, expected_width)				)
																			__lowerCAmelCase     =  max(snake_case_    ,				key=lambda snake_case_				: item[0]				)[0]
																			__lowerCAmelCase     =  max(snake_case_    ,				key=lambda snake_case_				: item[1]				)[1]

													return expected_height, expected_width
@require_torch
@require_vision
class       lowerCAmelCase_		(				A__				,				unittest.TestCase ):



							'''simple docstring'''





							_snake_case						      =		BridgeTowerImageProcessor if is_vision_available() else None




							def    A__						( self				)       ->  Optional[Any]:
													__lowerCAmelCase     =  BridgeTowerImageProcessingTester(self				)




							@property
							def    A__						( self				)       ->  Any:
													return self.image_processor_tester.prepare_image_processor_dict()




							def    A__						( self				)       ->  Optional[int]:
													__lowerCAmelCase     =  self.image_processing_class(**self.image_processor_dict				)
													self.assertTrue(hasattr(snake_case_    ,				"""image_mean"""				)				)
													self.assertTrue(hasattr(snake_case_    ,				"""image_std"""				)				)
													self.assertTrue(hasattr(snake_case_    ,				"""do_normalize"""				)				)
													self.assertTrue(hasattr(snake_case_    ,				"""do_resize"""				)				)
													self.assertTrue(hasattr(snake_case_    ,				"""size"""				)				)
													self.assertTrue(hasattr(snake_case_    ,				"""size_divisor"""				)				)




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




							def    A__						( self				)       ->  str:
													# Initialize image processor
													__lowerCAmelCase     =  self.image_processing_class(**self.image_processor_dict				)
													# create random PIL images
													__lowerCAmelCase     =  prepare_image_inputs(self.image_processor_tester    ,				equal_resolution=snake_case_				)
													for image in image_inputs:
																			self.assertIsInstance(snake_case_    ,				Image.Image				)

													# Test not batched input
													__lowerCAmelCase     =  image_processing(image_inputs[0]    ,				return_tensors="""pt"""				).pixel_values

													__lowerCAmelCase   ,     __lowerCAmelCase     =  self.image_processor_tester.get_expected_values(snake_case_				)
													self.assertEqual(
													    encoded_images.shape    ,				(1, self.image_processor_tester.num_channels, expected_height, expected_width)    ,				)

													# Test batched
													__lowerCAmelCase     =  image_processing(snake_case_    ,				return_tensors="""pt"""				).pixel_values

													__lowerCAmelCase   ,     __lowerCAmelCase     =  self.image_processor_tester.get_expected_values(snake_case_    ,				batched=snake_case_				)
													self.assertEqual(
													    encoded_images.shape    ,				(
													        self.image_processor_tester.batch_size,
													        self.image_processor_tester.num_channels,
													        expected_height,
													        expected_width,
													    )    ,				)




							def    A__						( self				)       ->  Any:
													# Initialize image processor
													__lowerCAmelCase     =  self.image_processing_class(**self.image_processor_dict				)
													# create random numpy tensors
													__lowerCAmelCase     =  prepare_image_inputs(self.image_processor_tester    ,				equal_resolution=snake_case_    ,				numpify=snake_case_				)
													for image in image_inputs:
																			self.assertIsInstance(snake_case_    ,				np.ndarray				)

													# Test not batched input
													__lowerCAmelCase     =  image_processing(image_inputs[0]    ,				return_tensors="""pt"""				).pixel_values

													__lowerCAmelCase   ,     __lowerCAmelCase     =  self.image_processor_tester.get_expected_values(snake_case_				)
													self.assertEqual(
													    encoded_images.shape    ,				(1, self.image_processor_tester.num_channels, expected_height, expected_width)    ,				)

													# Test batched
													__lowerCAmelCase     =  image_processing(snake_case_    ,				return_tensors="""pt"""				).pixel_values

													__lowerCAmelCase   ,     __lowerCAmelCase     =  self.image_processor_tester.get_expected_values(snake_case_    ,				batched=snake_case_				)
													self.assertEqual(
													    encoded_images.shape    ,				(
													        self.image_processor_tester.batch_size,
													        self.image_processor_tester.num_channels,
													        expected_height,
													        expected_width,
													    )    ,				)




							def    A__						( self				)       ->  Dict:
													# Initialize image processor
													__lowerCAmelCase     =  self.image_processing_class(**self.image_processor_dict				)
													# create random PyTorch tensors
													__lowerCAmelCase     =  prepare_image_inputs(self.image_processor_tester    ,				equal_resolution=snake_case_    ,				torchify=snake_case_				)
													for image in image_inputs:
																			self.assertIsInstance(snake_case_    ,				torch.Tensor				)

													# Test not batched input
													__lowerCAmelCase     =  image_processing(image_inputs[0]    ,				return_tensors="""pt"""				).pixel_values

													__lowerCAmelCase   ,     __lowerCAmelCase     =  self.image_processor_tester.get_expected_values(snake_case_				)
													self.assertEqual(
													    encoded_images.shape    ,				(1, self.image_processor_tester.num_channels, expected_height, expected_width)    ,				)

													# Test batched
													__lowerCAmelCase     =  image_processing(snake_case_    ,				return_tensors="""pt"""				).pixel_values

													__lowerCAmelCase   ,     __lowerCAmelCase     =  self.image_processor_tester.get_expected_values(snake_case_    ,				batched=snake_case_				)
													self.assertEqual(
													    encoded_images.shape    ,				(
													        self.image_processor_tester.batch_size,
													        self.image_processor_tester.num_channels,
													        expected_height,
													        expected_width,
													    )    ,				)


"""simple docstring"""
import os

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

												__lowerCAmelCase     =  0

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

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

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

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


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