'''simple docstring'''






import os





def  _SCREAMING_SNAKE_CASE		(      ):
     with open(os.path.dirname(__snake_case				) + '/grid.txt'				) as f:
          _A    		=  []  # noqa: E741
          for _ in range(2_0				):
               l.append([int(__snake_case				) for x in f.readline().split()]				)

          _A    		=  0

          # right
          for i in range(2_0				):
               for j in range(1_7				):
                    _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(1_7				):
               for j in range(2_0				):
                    _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(1_7				):
               for j in range(1_7				):
                    _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(1_7				):
               for j in range(3   ,		2_0				):
                    _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())




import itertools
import random
import unittest

import numpy as np

from transformers import is_speech_available
from transformers.testing_utils import require_torch, require_torchaudio

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_speech_available():
   from transformers import SpeechaTextFeatureExtractor

lowerCamelCase__  =					random.Random()


def 				lowerCAmelCase__       (			a__    ,     a__=1.0    ,     a__=None    ,     a__=None )      ->Optional[Any]:




  '''simple docstring'''

  if rng is None:
    _UpperCamelCase           =    global_rng

  _UpperCamelCase           =    []
  for batch_idx in range(shape[0] ):
    values.append([] )
    for _ in range(shape[1] ):
      values[-1].append(rng.random() * scale )

  return values




@require_torch
@require_torchaudio
class 					_UpperCAmelCase			(     unittest.TestCase  ):



 '''simple docstring'''




 def __init__(		self				:   Optional[Any]							, lowercase_				:   List[str]							, lowercase_				:   List[str]=7							, lowercase_				:   List[str]=400							, lowercase_				:   str=2000							, lowercase_				:   Optional[int]=24							, lowercase_				:   Optional[int]=24							, lowercase_				:   Tuple=0.0							, lowercase_				:   Any=16000							, lowercase_				:   Any=True							, lowercase_				:   Optional[int]=True							, )						->	Union[str, Any]:


   """simple docstring"""







   _UpperCamelCase           =    parent
   _UpperCamelCase           =    batch_size
   _UpperCamelCase           =    min_seq_length
   _UpperCamelCase           =    max_seq_length
   _UpperCamelCase           =    (self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
   _UpperCamelCase           =    feature_size
   _UpperCamelCase           =    num_mel_bins
   _UpperCamelCase           =    padding_value
   _UpperCamelCase           =    sampling_rate
   _UpperCamelCase           =    return_attention_mask
   _UpperCamelCase           =    do_normalize







 def 		__UpperCAmelCase				(		self				:   int)						->	str:


   """simple docstring"""







   return {
       "feature_size": self.feature_size,
       "num_mel_bins": self.num_mel_bins,
       "padding_value": self.padding_value,
       "sampling_rate": self.sampling_rate,
       "return_attention_mask": self.return_attention_mask,
       "do_normalize": self.do_normalize,
   }







 def 		__UpperCAmelCase				(		self				:   Tuple							, lowercase_				:   Optional[Any]=False							, lowercase_				:   int=False)						->	Dict:


   """simple docstring"""







   def _flatten(lowercase_				:   str):
     return list(itertools.chain(*lowercase_))

   if equal_length:
     _UpperCamelCase           =    [floats_list((self.max_seq_length, self.feature_size)) for _ in range(self.batch_size)]
   else:
     # make sure that inputs increase in size
     _UpperCamelCase           =    [
         floats_list((x, self.feature_size))
         for x in range(self.min_seq_length							, self.max_seq_length							, self.seq_length_diff)
     ]
   if numpify:
     _UpperCamelCase           =    [np.asarray(lowercase_) for x in speech_inputs]
   return speech_inputs




@require_torch
@require_torchaudio
class 					_UpperCAmelCase			(     lowerCAmelCase,			unittest.TestCase  ):



 '''simple docstring'''




 __A			       =					SpeechaTextFeatureExtractor if is_speech_available() else None







 def 		__UpperCAmelCase				(		self				:   Optional[int])						->	List[Any]:


   """simple docstring"""







   _UpperCamelCase           =    SpeechaTextFeatureExtractionTester(self)







 def 		__UpperCAmelCase				(		self				:   Dict							, lowercase_				:   Tuple)						->	int:


   """simple docstring"""







   self.assertTrue(np.all(np.mean(lowercase_							, axis=0) < 1e-3))
   self.assertTrue(np.all(np.abs(np.var(lowercase_							, axis=0) - 1) < 1e-3))







 def 		__UpperCAmelCase				(		self				:   List[Any])						->	int:


   """simple docstring"""







   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   # create three inputs of length 800, 1000, and 1200
   _UpperCamelCase           =    [floats_list((1, x))[0] for x in range(800							, 1400							, 200)]
   _UpperCamelCase           =    [np.asarray(lowercase_) for speech_input in speech_inputs]

   # Test feature size
   _UpperCamelCase           =    feature_extractor(lowercase_							, padding=lowercase_							, return_tensors="np").input_features
   self.assertTrue(input_features.ndim == 3)
   self.assertTrue(input_features.shape[-1] == feature_extractor.feature_size)

   # Test not batched input
   _UpperCamelCase           =    feature_extractor(speech_inputs[0]							, return_tensors="np").input_features
   _UpperCamelCase           =    feature_extractor(np_speech_inputs[0]							, return_tensors="np").input_features
   self.assertTrue(np.allclose(lowercase_							, lowercase_							, atol=1e-3))

   # Test batched
   _UpperCamelCase           =    feature_extractor(lowercase_							, return_tensors="np").input_features
   _UpperCamelCase           =    feature_extractor(lowercase_							, return_tensors="np").input_features
   for enc_seq_a, enc_seq_a in zip(lowercase_							, lowercase_):
     self.assertTrue(np.allclose(lowercase_							, lowercase_							, atol=1e-3))

   # Test 2-D numpy arrays are batched.
   _UpperCamelCase           =    [floats_list((1, x))[0] for x in (800, 800, 800)]
   _UpperCamelCase           =    np.asarray(lowercase_)
   _UpperCamelCase           =    feature_extractor(lowercase_							, return_tensors="np").input_features
   _UpperCamelCase           =    feature_extractor(lowercase_							, return_tensors="np").input_features
   for enc_seq_a, enc_seq_a in zip(lowercase_							, lowercase_):
     self.assertTrue(np.allclose(lowercase_							, lowercase_							, atol=1e-3))







 def 		__UpperCAmelCase				(		self				:   Dict)						->	List[Any]:


   """simple docstring"""







   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   _UpperCamelCase           =    [floats_list((1, x))[0] for x in range(800							, 1400							, 200)]

   _UpperCamelCase           =    ["longest", "max_length", "do_not_pad"]
   _UpperCamelCase           =    [None, 16, None]
   for max_length, padding in zip(lowercase_							, lowercase_):
     _UpperCamelCase           =    feature_extractor(
         lowercase_							, padding=lowercase_							, max_length=lowercase_							, return_attention_mask=lowercase_)
     _UpperCamelCase           =    inputs.input_features
     _UpperCamelCase           =    inputs.attention_mask
     _UpperCamelCase           =    [np.sum(lowercase_) for x in attention_mask]

     self._check_zero_mean_unit_variance(input_features[0][: fbank_feat_lengths[0]])
     self._check_zero_mean_unit_variance(input_features[1][: fbank_feat_lengths[1]])
     self._check_zero_mean_unit_variance(input_features[2][: fbank_feat_lengths[2]])







 def 		__UpperCAmelCase				(		self				:   int)						->	str:


   """simple docstring"""







   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   _UpperCamelCase           =    [floats_list((1, x))[0] for x in range(800							, 1400							, 200)]

   _UpperCamelCase           =    ["longest", "max_length", "do_not_pad"]
   _UpperCamelCase           =    [None, 16, None]
   for max_length, padding in zip(lowercase_							, lowercase_):
     _UpperCamelCase           =    feature_extractor(
         lowercase_							, max_length=lowercase_							, padding=lowercase_							, return_tensors="np"							, return_attention_mask=lowercase_)
     _UpperCamelCase           =    inputs.input_features
     _UpperCamelCase           =    inputs.attention_mask
     _UpperCamelCase           =    [np.sum(lowercase_) for x in attention_mask]

     self._check_zero_mean_unit_variance(input_features[0][: fbank_feat_lengths[0]])
     self.assertTrue(input_features[0][fbank_feat_lengths[0] :].sum() < 1e-6)
     self._check_zero_mean_unit_variance(input_features[1][: fbank_feat_lengths[1]])
     self.assertTrue(input_features[0][fbank_feat_lengths[1] :].sum() < 1e-6)
     self._check_zero_mean_unit_variance(input_features[2][: fbank_feat_lengths[2]])







 def 		__UpperCAmelCase				(		self				:   int)						->	Optional[int]:


   """simple docstring"""







   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   _UpperCamelCase           =    [floats_list((1, x))[0] for x in range(800							, 1400							, 200)]
   _UpperCamelCase           =    feature_extractor(
       lowercase_							, padding="max_length"							, max_length=4							, truncation=lowercase_							, return_tensors="np"							, return_attention_mask=lowercase_							, )
   _UpperCamelCase           =    inputs.input_features
   _UpperCamelCase           =    inputs.attention_mask
   _UpperCamelCase           =    np.sum(attention_mask == 1							, axis=1)

   self._check_zero_mean_unit_variance(input_features[0, : fbank_feat_lengths[0]])
   self._check_zero_mean_unit_variance(input_features[1])
   self._check_zero_mean_unit_variance(input_features[2])







 def 		__UpperCAmelCase				(		self				:   Dict)						->	Optional[int]:


   """simple docstring"""







   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   _UpperCamelCase           =    [floats_list((1, x))[0] for x in range(800							, 1400							, 200)]
   _UpperCamelCase           =    feature_extractor(
       lowercase_							, padding="longest"							, max_length=4							, truncation=lowercase_							, return_tensors="np"							, return_attention_mask=lowercase_							, )
   _UpperCamelCase           =    inputs.input_features
   _UpperCamelCase           =    inputs.attention_mask
   _UpperCamelCase           =    np.sum(attention_mask == 1							, axis=1)

   self._check_zero_mean_unit_variance(input_features[0, : fbank_feat_lengths[0]])
   self._check_zero_mean_unit_variance(input_features[1, : fbank_feat_lengths[1]])
   self._check_zero_mean_unit_variance(input_features[2])

   # make sure that if max_length < longest -> then pad to max_length
   self.assertEqual(input_features.shape							, (3, 4, 24))

   _UpperCamelCase           =    [floats_list((1, x))[0] for x in range(800							, 1400							, 200)]
   _UpperCamelCase           =    feature_extractor(
       lowercase_							, padding="longest"							, max_length=16							, truncation=lowercase_							, return_tensors="np"							, return_attention_mask=lowercase_							, )
   _UpperCamelCase           =    inputs.input_features
   _UpperCamelCase           =    inputs.attention_mask
   _UpperCamelCase           =    np.sum(attention_mask == 1							, axis=1)

   self._check_zero_mean_unit_variance(input_features[0, : fbank_feat_lengths[0]])
   self._check_zero_mean_unit_variance(input_features[1, : fbank_feat_lengths[1]])
   self._check_zero_mean_unit_variance(input_features[2])

   # make sure that if max_length < longest -> then pad to max_length
   self.assertEqual(input_features.shape							, (3, 6, 24))







 def 		__UpperCAmelCase				(		self				:   Tuple)						->	Dict:


   """simple docstring"""







   import torch

   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   _UpperCamelCase           =    np.random.rand(100							, 32).astype(np.floataa)
   _UpperCamelCase           =    np_speech_inputs.tolist()

   for inputs in [py_speech_inputs, np_speech_inputs]:
     _UpperCamelCase           =    feature_extractor.pad([{"input_features": inputs}]							, return_tensors="np")
     self.assertTrue(np_processed.input_features.dtype == np.floataa)
     _UpperCamelCase           =    feature_extractor.pad([{"input_features": inputs}]							, return_tensors="pt")
     self.assertTrue(pt_processed.input_features.dtype == torch.floataa)







 def 		__UpperCAmelCase				(		self				:   str							, lowercase_				:   List[str])						->	Dict:


   """simple docstring"""







   from datasets import load_dataset

   _UpperCamelCase           =    load_dataset("hf-internal-testing/librispeech_asr_dummy"							, "clean"							, split="validation")
   # automatic decoding with librispeech
   _UpperCamelCase           =    ds.sort("id").select(range(lowercase_))[:num_samples]["audio"]

   return [x["array"] for x in speech_samples]







 def 		__UpperCAmelCase				(		self				:   str)						->	Tuple:


   """simple docstring"""







   _UpperCamelCase           =    np.array([
       -1.57_45, -1.77_13, -1.70_20, -1.60_69, -1.22_50, -1.11_05, -0.90_72, -0.82_41,
       -1.23_10, -0.80_98, -0.33_20, -0.41_01, -0.79_85, -0.49_96, -0.82_13, -0.91_28,
       -1.04_20, -1.12_86, -1.04_40, -0.79_99, -0.84_05, -1.22_75, -1.54_43, -1.46_25,
   ])
   # fmt: on

   _UpperCamelCase           =    self._load_datasamples(1)
   _UpperCamelCase           =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
   _UpperCamelCase           =    feature_extractor(lowercase_							, return_tensors="pt").input_features
   self.assertEquals(input_features.shape							, (1, 584, 24))
   self.assertTrue(np.allclose(input_features[0, 0, :30]							, lowercase_							, atol=1e-4))




