

import torch

from transformers import AutoModel





class 				__lowerCAmelCase  (      torch.nn.Module							):




  def __init__(       self							,     lowerCAmelCase="sayef/fsner-bert-base-uncased"      )						->				Dict:
        '''simple docstring'''






        super(lowerCAmelCase							,     self      ).__init__()

        _lowercase			 =AutoModel.from_pretrained(lowerCAmelCase							,     return_dict=lowerCAmelCase      )
        _lowercase			 =torch.nn.CosineSimilarity(3							,     1e-08      )
        _lowercase			 =torch.nn.Softmax(dim=1      )




  def 						A__  (       self							,     **lowerCAmelCase      )						->				Optional[Any]:
        '''simple docstring'''






        return self.bert(**lowerCAmelCase      ).last_hidden_state




  def 						A__  (       self							,     lowerCAmelCase      )						->				List[Any]:
        '''simple docstring'''






        return token_embeddings.sum(2							,     keepdim=lowerCAmelCase      )




  def 						A__  (       self							,     lowerCAmelCase							,     lowerCAmelCase							,     lowerCAmelCase=1      )						->				List[Any]:
        '''simple docstring'''






        return self.softmax(T * self.cos(lowerCAmelCase							,     lowerCAmelCase      )      )




  def 						A__  (       self							,     lowerCAmelCase							,     lowerCAmelCase      )						->				List[Any]:
        '''simple docstring'''






        _lowercase			 =W_supports['sizes'].tolist()
        _lowercase			 =W_supports['start_token_id'].item()
        _lowercase			 =W_supports['end_token_id'].item()

        del W_supports["sizes"]
        del W_supports["start_token_id"]
        del W_supports["end_token_id"]

        _lowercase			 =self.BERT(**lowerCAmelCase      )
        _lowercase			 =self.BERT(**lowerCAmelCase      )

        _lowercase			 =None
        _lowercase			 =None

        _lowercase			 =W_supports['input_ids'] == start_token_id
        _lowercase			 =W_supports['input_ids'] == end_token_id

        for i, size in enumerate(lowerCAmelCase      ):
              if i == 0:
                    _lowercase			 =0
              else:
                    _lowercase			 =support_sizes[i - 1]

              _lowercase			 =S[s : s + size][start_token_masks[s : s + size]]
              _lowercase			 =S[s : s + size][end_token_masks[s : s + size]]

              _lowercase			 =torch.matmul(q[i]							,     s_start.T      ).sum(1      ).softmax(0      )
              _lowercase			 =torch.matmul(q[i]							,     s_end.T      ).sum(1      ).softmax(0      )

              if p_starts is not None:
                    _lowercase			 =torch.vstack((p_starts, p_start)      )
                    _lowercase			 =torch.vstack((p_ends, p_end)      )
              else:
                    _lowercase			 =p_start
                    _lowercase			 =p_end

        return p_starts, p_ends





import os
def   a   (    )					->   Optional[int]:





      """simple docstring"""



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

            _lowercase			 =0

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

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

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

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


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


