






'''simple docstring'''







import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
  import torch

  from transformers import (
      MODEL_FOR_PRETRAINING_MAPPING,
      AlbertForMaskedLM,
      AlbertForMultipleChoice,
      AlbertForPreTraining,
      AlbertForQuestionAnswering,
      AlbertForSequenceClassification,
      AlbertForTokenClassification,
      AlbertModel,
  )
  from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST




class   __SCREAMING_SNAKE_CASE       :


  """simple docstring"""


  def __init__(			self   ,	UpperCamelCase__   ,	UpperCamelCase__=13   ,	UpperCamelCase__=7   ,	UpperCamelCase__=True   ,	UpperCamelCase__=True   ,	UpperCamelCase__=True   ,	UpperCamelCase__=True   ,	UpperCamelCase__=99   ,	UpperCamelCase__=16   ,	UpperCamelCase__=36   ,	UpperCamelCase__=6   ,	UpperCamelCase__=6   ,	UpperCamelCase__=6   ,	UpperCamelCase__=37   ,	UpperCamelCase__="gelu"   ,	UpperCamelCase__=0.1   ,	UpperCamelCase__=0.1   ,	UpperCamelCase__=512   ,	UpperCamelCase__=16   ,	UpperCamelCase__=2   ,	UpperCamelCase__=0.02   ,	UpperCamelCase__=3   ,	UpperCamelCase__=4   ,	UpperCamelCase__=None   ,	):






         """simple docstring"""


         a_						     =			parent
         a_						     =			batch_size
         a_						     =			seq_length
         a_						     =			is_training
         a_						     =			use_input_mask
         a_						     =			use_token_type_ids
         a_						     =			use_labels
         a_						     =			vocab_size
         a_						     =			embedding_size
         a_						     =			hidden_size
         a_						     =			num_hidden_layers
         a_						     =			num_hidden_groups
         a_						     =			num_attention_heads
         a_						     =			intermediate_size
         a_						     =			hidden_act
         a_						     =			hidden_dropout_prob
         a_						     =			attention_probs_dropout_prob
         a_						     =			max_position_embeddings
         a_						     =			type_vocab_size
         a_						     =			type_sequence_label_size
         a_						     =			initializer_range
         a_						     =			num_labels
         a_						     =			num_choices
         a_						     =			scope







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			ids_tensor([self.batch_size, self.seq_length]   ,	self.vocab_size	)

         a_						     =			None
         if self.use_input_mask:
                a_						     =			random_attention_mask([self.batch_size, self.seq_length]	)

         a_						     =			None
         if self.use_token_type_ids:
                a_						     =			ids_tensor([self.batch_size, self.seq_length]   ,	self.type_vocab_size	)

         a_						     =			None
         a_						     =			None
         a_						     =			None
         if self.use_labels:
                a_						     =			ids_tensor([self.batch_size]   ,	self.type_sequence_label_size	)
                a_						     =			ids_tensor([self.batch_size, self.seq_length]   ,	self.num_labels	)
                a_						     =			ids_tensor([self.batch_size]   ,	self.num_choices	)

         a_						     =			self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







  def    _a       (			self	):






         """simple docstring"""


         return AlbertConfig(
             vocab_size=self.vocab_size   ,	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   ,	max_position_embeddings=self.max_position_embeddings   ,	type_vocab_size=self.type_vocab_size   ,	initializer_range=self.initializer_range   ,	num_hidden_groups=self.num_hidden_groups   ,	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			AlbertModel(config=_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			model(_lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase	)
         a_						     =			model(_lowerCamelCase   ,	token_type_ids=_lowerCamelCase	)
         a_						     =			model(_lowerCamelCase	)
         self.parent.assertEqual(result.last_hidden_state.shape   ,	(self.batch_size, self.seq_length, self.hidden_size)	)
         self.parent.assertEqual(result.pooler_output.shape   ,	(self.batch_size, self.hidden_size)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			AlbertForPreTraining(config=_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			model(
             _lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase   ,	labels=_lowerCamelCase   ,	sentence_order_label=_lowerCamelCase   ,	)
         self.parent.assertEqual(result.prediction_logits.shape   ,	(self.batch_size, self.seq_length, self.vocab_size)	)
         self.parent.assertEqual(result.sop_logits.shape   ,	(self.batch_size, config.num_labels)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			AlbertForMaskedLM(config=_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			model(_lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase   ,	labels=_lowerCamelCase	)
         self.parent.assertEqual(result.logits.shape   ,	(self.batch_size, self.seq_length, self.vocab_size)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			AlbertForQuestionAnswering(config=_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			model(
             _lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase   ,	start_positions=_lowerCamelCase   ,	end_positions=_lowerCamelCase   ,	)
         self.parent.assertEqual(result.start_logits.shape   ,	(self.batch_size, self.seq_length)	)
         self.parent.assertEqual(result.end_logits.shape   ,	(self.batch_size, self.seq_length)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			self.num_labels
         a_						     =			AlbertForSequenceClassification(_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			model(_lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase   ,	labels=_lowerCamelCase	)
         self.parent.assertEqual(result.logits.shape   ,	(self.batch_size, self.num_labels)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			self.num_labels
         a_						     =			AlbertForTokenClassification(config=_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			model(_lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase   ,	labels=_lowerCamelCase	)
         self.parent.assertEqual(result.logits.shape   ,	(self.batch_size, self.seq_length, self.num_labels)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			self.num_choices
         a_						     =			AlbertForMultipleChoice(config=_lowerCamelCase	)
         model.to(_lowerCamelCase	)
         model.eval()
         a_						     =			input_ids.unsqueeze(1	).expand(-1   ,	self.num_choices   ,	-1	).contiguous()
         a_						     =			token_type_ids.unsqueeze(1	).expand(-1   ,	self.num_choices   ,	-1	).contiguous()
         a_						     =			input_mask.unsqueeze(1	).expand(-1   ,	self.num_choices   ,	-1	).contiguous()
         a_						     =			model(
             _lowerCamelCase   ,	attention_mask=_lowerCamelCase   ,	token_type_ids=_lowerCamelCase   ,	labels=_lowerCamelCase   ,	)
         self.parent.assertEqual(result.logits.shape   ,	(self.batch_size, self.num_choices)	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.prepare_config_and_inputs()
         (
             (
             a_
         )     ,	(
             a_
         )     ,	(
             a_
         )     ,	(
             a_
         )     ,	(
             a_
         )     ,	(
             a_
         )     ,	(
             a_
         )     ,	
         )						     =			config_and_inputs
         a_						     =			{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
         return config, inputs_dict





@require_torch
class   __SCREAMING_SNAKE_CASE       (__a							,       __a							,       unittest.TestCase       ):


  """simple docstring"""


  _a  : Tuple      			=     (
      (
          AlbertModel,
          AlbertForPreTraining,
          AlbertForMaskedLM,
          AlbertForMultipleChoice,
          AlbertForSequenceClassification,
          AlbertForTokenClassification,
          AlbertForQuestionAnswering,
      )
      if is_torch_available()
      else ()
  )
  _a  : Tuple      			=     (
      {
          'feature-extraction': AlbertModel,
          'fill-mask': AlbertForMaskedLM,
          'question-answering': AlbertForQuestionAnswering,
          'text-classification': AlbertForSequenceClassification,
          'token-classification': AlbertForTokenClassification,
          'zero-shot': AlbertForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )
  _a  : List[str]      			=     True







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__=False	):






         """simple docstring"""


         a_						     =			super()._prepare_for_class(_lowerCamelCase   ,	_lowerCamelCase   ,	return_labels=_lowerCamelCase	)

         if return_labels:
                if model_class in get_values(_lowerCamelCase	):
                       a_						     =			torch.zeros(
                           (self.model_tester.batch_size, self.model_tester.seq_length)   ,	dtype=torch.long   ,	device=_lowerCamelCase	)
                       a_						     =			torch.zeros(
                           self.model_tester.batch_size   ,	dtype=torch.long   ,	device=_lowerCamelCase	)
         return inputs_dict







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			AlbertModelTester(self	)
         a_						     =			ConfigTester(self   ,	config_class=_lowerCamelCase   ,	hidden_size=37	)







  def    _a       (			self	):






         """simple docstring"""


         self.config_tester.run_common_tests()







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*_lowerCamelCase	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_pretraining(*_lowerCamelCase	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_lm(*_lowerCamelCase	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_multiple_choice(*_lowerCamelCase	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*_lowerCamelCase	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*_lowerCamelCase	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
                a_						     =			type
                self.model_tester.create_and_check_model(*_lowerCamelCase	)







  @slow
  def    _a       (			self	):






         """simple docstring"""


         for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                a_						     =			AlbertModel.from_pretrained(_lowerCamelCase	)
                self.assertIsNotNone(_lowerCamelCase	)





@require_torch
class   __SCREAMING_SNAKE_CASE       (unittest.TestCase       ):


  """simple docstring"""


  @slow
  def    _a       (			self	):






         """simple docstring"""


         a_						     =			AlbertModel.from_pretrained('albert-base-v2'	)
         a_						     =			torch.tensor([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]]	)
         a_						     =			torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]	)
         with torch.no_grad():
                a_						     =			model(_lowerCamelCase   ,	attention_mask=_lowerCamelCase	)[0]
         a_						     =			torch.Size((1, 11, 768)	)
         self.assertEqual(output.shape   ,	_lowerCamelCase	)
         a_						     =			torch.tensor(
             [[[-0.6_513, 1.5_035, -0.2_766], [-0.6_515, 1.5_046, -0.2_780], [-0.6_512, 1.5_049, -0.2_784]]]	)

         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]   ,	_lowerCamelCase   ,	atol=1e-4	)	)





'''simple docstring'''

import os



def snake_case_      (					__snake_case  :							List[Any])			->					str:
   lowerCAmelCase_			=      len(grid[0])
   lowerCAmelCase_			=      len(__snake_case)

   lowerCAmelCase_			=      0
   lowerCAmelCase_			=      0
   lowerCAmelCase_			=      0

   # Check vertically, horizontally, diagonally at the same time (only works
   # for nxn grid)
   for i in range(__snake_case):
      for j in range(n_rows - 3):
         lowerCAmelCase_			=      grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
         lowerCAmelCase_			=      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:
            lowerCAmelCase_			=      (
                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:
            lowerCAmelCase_			=      (
                grid[i][j]
                * grid[i - 1][j + 1]
                * grid[i - 2][j + 2]
                * grid[i - 3][j + 3]
            )

         lowerCAmelCase_			=      max(
             __snake_case	,   __snake_case	,   __snake_case	,   __snake_case)
         if max_product > largest:
            lowerCAmelCase_			=      max_product

   return largest



def snake_case_      (					)			->					List[Any]:
   lowerCAmelCase_			=      []
   with open(os.path.dirname(__snake_case) + '''/grid.txt''') as file:
      for line in file:
         grid.append(line.strip('''\n''').split(''' '''))

   lowerCAmelCase_			=      [[int(__snake_case) for i in grid[j]] for j in range(len(__snake_case))]

   return largest_product(__snake_case)


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





