

import os
from shutil import copyfile
from typing import List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


lowerCamelCase           =					logging.get_logger(__name__)

lowerCamelCase           =					{'''vocab_file''': '''sentencepiece.model'''}

lowerCamelCase           =					{
    '''vocab_file''': {
        '''google/rembert''': '''https://huggingface.co/google/rembert/resolve/main/sentencepiece.model''',
    },
}

lowerCamelCase           =					{
    '''google/rembert''': 256,
}







class 						__magic_name__			(							lowerCamelCase__							):

   '''simple docstring'''




   lowerCamelCase__ :	Optional[Any]    =   VOCAB_FILES_NAMES
   lowerCamelCase__ :	List[Any]    =   PRETRAINED_VOCAB_FILES_MAP
   lowerCamelCase__ :	Union[str, Any]    =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES



   def __init__(				self,    lowercase_,    lowercase_=False,    lowercase_=True,    lowercase_=True,    lowercase_="[CLS]",    lowercase_="[SEP]",    lowercase_="[UNK]",    lowercase_="[SEP]",    lowercase_="[PAD]",    lowercase_="[CLS]",    lowercase_="[MASK]",    **lowercase_,    )							->    str:






     """simple docstring"""






     super().__init__(
         do_lower_case=lowercase_,    remove_space=lowercase_,    keep_accents=lowercase_,    bos_token=lowercase_,    eos_token=lowercase_,    unk_token=lowercase_,    sep_token=lowercase_,    pad_token=lowercase_,    cls_token=lowercase_,    mask_token=lowercase_,    **lowercase_,    )

     a__  =do_lower_case
     a__  =remove_space
     a__  =keep_accents
     a__  =vocab_file

     a__  =spm.SentencePieceProcessor()
     self.sp_model.Load(lowercase_       )



   @property
   def  _UpperCAmelCase (				self       )							->    Optional[int]:






     """simple docstring"""






     return len(self.sp_model       )



   def  _UpperCAmelCase (				self       )							->    List[Any]:






     """simple docstring"""






     a__  ={self.convert_ids_to_tokens(lowercase_       ): i for i in range(self.vocab_size       )}
     vocab.update(self.added_tokens_encoder       )
     return vocab



   def __getstate__(				self       )							->    Any:






     """simple docstring"""






     a__  =self.__dict__.copy()
     a__  =None
     return state



   def __setstate__(				self,    lowercase_       )							->    Any:






     """simple docstring"""






     a__  =d
     a__  =spm.SentencePieceProcessor()
     self.sp_model.Load(self.vocab_file       )



   def  _UpperCAmelCase (				self,    lowercase_,    lowercase_=False       )							->    Any:






     """simple docstring"""






     a__  =self.sp_model.EncodeAsPieces(lowercase_       )
     return pieces



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






     """simple docstring"""






     return self.sp_model.PieceToId(lowercase_       )



   def  _UpperCAmelCase (				self,    lowercase_       )							->    Any:






     """simple docstring"""






     return self.sp_model.IdToPiece(lowercase_       )



   def  _UpperCAmelCase (				self,    lowercase_       )							->    int:






     """simple docstring"""






     a__  =self.sp_model.decode_pieces(lowercase_       )
     return out_string



   def  _UpperCAmelCase (				self,    lowercase_,    lowercase_ = None       )							->    List[int]:






     """simple docstring"""






     a__  =[self.sep_token_id]
     a__  =[self.cls_token_id]
     if token_ids_a is None:
       return cls + token_ids_a + sep
     return cls + token_ids_a + sep + token_ids_a + sep



   def  _UpperCAmelCase (				self,    lowercase_,    lowercase_ = None,    lowercase_ = False       )							->    List[int]:






     """simple docstring"""






     if already_has_special_tokens:
       if token_ids_a is not None:
         raise ValueError(
             '''You should not supply a second sequence if the provided sequence of '''
             '''ids is already formatted with special tokens for the model.'''       )
       return [1 if x in [self.sep_token_id, self.cls_token_id] else 0 for x in token_ids_a]

     if token_ids_a is not None:
       return [1] + ([0] * len(lowercase_       )) + [1] + ([0] * len(lowercase_       )) + [1]
     return [1] + ([0] * len(lowercase_       )) + [1]



   def  _UpperCAmelCase (				self,    lowercase_,    lowercase_ = None       )							->    List[int]:






     """simple docstring"""






     a__  =[self.sep_token_id]
     a__  =[self.cls_token_id]

     if token_ids_a is None:
       return len(cls + token_ids_a + sep       ) * [0]
     return len(cls + token_ids_a + sep       ) * [0] + len(token_ids_a + sep       ) * [1]



   def  _UpperCAmelCase (				self,    lowercase_,    lowercase_ = None       )							->    Tuple[str]:






     """simple docstring"""






     if not os.path.isdir(lowercase_       ):
       logger.error('''Vocabulary path ({}) should be a directory'''.format(lowercase_       )       )
       return
     a__  =os.path.join(
         lowercase_,    (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']       )

     if os.path.abspath(self.vocab_file       ) != os.path.abspath(lowercase_       ):
       copyfile(self.vocab_file,    lowercase_       )

     return (out_vocab_file,)



import os




def 			UpperCAmelCase__				(			_A      : Any							):





  '''simple docstring'''







  a__  =len(grid[0]							)
  a__  =len(_A							)

  a__  =0
  a__  =0
  a__  =0

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

      a__  =max(
          _A	,      _A	,      _A	,      _A							)
      if max_product > largest:
        a__  =max_product

  return largest




def 			UpperCAmelCase__				(			):





  '''simple docstring'''







  a__  =[]
  with open(os.path.dirname(_A							) + '''/grid.txt'''							) as file:
    for line in file:
      grid.append(line.strip('''\n'''							).split(''' '''							)							)

  a__  =[[int(_A							) for i in grid[j]] for j in range(len(_A							)							)]

  return largest_product(_A							)


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