



"""simple docstring"""

import os

import pytest
from attr import dataclass


lowercase__			   =  """us-east-1"""  # defaults region




@dataclass
class SCREAMING_SNAKE_CASE__					:
						_lowerCAmelCase							=					4_2
						_lowerCAmelCase							=					"arn:aws:iam::558105141721:role/sagemaker_execution_role"
						_lowerCAmelCase							=					{
						    "task_name": "mnli",
						    "per_device_train_batch_size": 1_6,
						    "per_device_eval_batch_size": 1_6,
						    "do_train": True,
						    "do_eval": True,
						    "do_predict": True,
						    "output_dir": "/opt/ml/model",
						    "overwrite_output_dir": True,
						    "max_steps": 5_0_0,
						    "save_steps": 5_5_0_0,
						}
						_lowerCAmelCase							=					{**hyperparameters, "max_steps": 1_0_0_0}



						@property
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													if self.framework == "pytorch":
																				return [
																				    {"Name": "train_runtime", "Regex": r"train_runtime.*=\D*(.*?)$"},
																				    {"Name": "eval_accuracy", "Regex": r"eval_accuracy.*=\D*(.*?)$"},
																				    {"Name": "eval_loss", "Regex": r"eval_loss.*=\D*(.*?)$"},
																				]
													else:
																				return [
																				    {"Name": "train_runtime", "Regex": r"train_runtime.*=\D*(.*?)$"},
																				    {"Name": "eval_accuracy", "Regex": r"loss.*=\D*(.*?)]?$"},
																				    {"Name": "eval_loss", "Regex": r"sparse_categorical_accuracy.*=\D*(.*?)]?$"},
																				]



						@property
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													return F'''{self.framework}-transfromers-test'''



						@property
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													return F'''./tests/sagemaker/scripts/{self.framework}'''





						@property
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													if self.framework == "pytorch":
																				return "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-training:1.7.1-transformers4.6.1-gpu-py36-cu110-ubuntu18.04"
													else:
																				return "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-tensorflow-training:2.4.1-transformers4.6.1-gpu-py37-cu110-ubuntu18.04"







@pytest.fixture(scope="""class"""					)
def       __magic_name__    (   _lowerCamelCase				: List[str]					):
							__a		:		Tuple									=       SageMakerTestEnvironment(framework=request.cls.framework					)






"""simple docstring"""

import os





def       __magic_name__    (   _lowerCamelCase				: Dict					):
							__a		:		List[str]									=       len(grid[0]					)
							__a		:		int									=       len(_lowerCamelCase					)

							__a		:		Tuple									=       0
							__a		:		List[Any]									=       0
							__a		:		List[str]									=       0

							# Check vertically, horizontally, diagonally at the same time (only works
							# for nxn grid)
							for i in range(_lowerCamelCase					):
														for j in range(n_rows - 3					):
																					__a		:		List[Any]									=       grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
																					__a		:		Tuple									=       grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

																					# Left-to-right diagonal (\) product
																					if i < n_columns - 3:
																												__a		:		List[Any]									=       (
																												    grid[i][j]
																												    * grid[i + 1][j + 1]
																												    * grid[i + 2][j + 2]
																												    * grid[i + 3][j + 3]
																												)

																					# Right-to-left diagonal(/) product
																					if i > 2:
																												__a		:		List[Any]									=       (
																												    grid[i][j]
																												    * grid[i - 1][j + 1]
																												    * grid[i - 2][j + 2]
																												    * grid[i - 3][j + 3]
																												)

																					__a		:		str									=       max(
																					    _lowerCamelCase  ,       _lowerCamelCase  ,       _lowerCamelCase  ,       _lowerCamelCase					)
																					if max_product > largest:
																												__a		:		Optional[Any]									=       max_product

							return largest





def       __magic_name__    (   ):
							__a		:		Tuple									=       []
							with open(os.path.dirname(_lowerCamelCase					) + """/grid.txt"""					) as file:
														for line in file:
																					grid.append(line.strip("""\n"""					).split(""" """					)					)

							__a		:		Tuple									=       [[int(_lowerCamelCase					) for i in grid[j]] for j in range(len(_lowerCamelCase					)					)]

							return largest_product(_lowerCamelCase					)


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

