





import os
import unittest

from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer

from ...test_tokenization_common import TokenizerTesterMixin



class     _UpperCAmelCase   (   _UpperCamelCase		,   unittest.TestCase   ):

  """simple docstring"""


  a_      =			PhobertTokenizer
  a_      =			False






  def     lowercase		(    self			:		Any					)							->						Tuple:
     super().setUp()

     # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
     __lowerCAmelCase							     =     ['T@@', 'i', 'I', 'R@@', 'r', 'e@@']
     __lowerCAmelCase							     =     dict(zip(lowerCAmelCase_ ,  range(len(lowerCAmelCase_					)					)					)					)
     __lowerCAmelCase							     =     ['#version: 0.2', 'l à</w>']
     __lowerCAmelCase							     =     {'unk_token': '<unk>'}

     __lowerCAmelCase							     =     os.path.join(self.tmpdirname ,  VOCAB_FILES_NAMES['vocab_file']					)
     __lowerCAmelCase							     =     os.path.join(self.tmpdirname ,  VOCAB_FILES_NAMES['merges_file']					)

     with open(self.vocab_file ,  'w' ,  encoding='utf-8'					) as fp:
        for token in vocab_tokens:
           fp.write(f"""{token} {vocab_tokens[token]}\n"""					)
     with open(self.merges_file ,  'w' ,  encoding='utf-8'					) as fp:
        fp.write('\n'.join(lowerCAmelCase_					)					)






  def     lowercase		(    self			:		str ,  **lowerCAmelCase_			:		List[str]					)							->						Dict:
     kwargs.update(self.special_tokens_map					)
     return PhobertTokenizer.from_pretrained(self.tmpdirname ,  **lowerCAmelCase_					)






  def     lowercase		(    self			:		Dict ,  lowerCAmelCase_			:		List[Any]					)							->						Tuple:
     __lowerCAmelCase							     =     'Tôi là VinAI Research'
     __lowerCAmelCase							     =     'T<unk> i <unk> <unk> <unk> <unk> <unk> <unk> I Re<unk> e<unk> <unk> <unk> <unk>'
     return input_text, output_text






  def     lowercase		(    self			:		int					)							->						Union[str, Any]:
     __lowerCAmelCase							     =     PhobertTokenizer(self.vocab_file ,  self.merges_file ,  **self.special_tokens_map					)
     __lowerCAmelCase							     =     'Tôi là VinAI Research'
     __lowerCAmelCase							     =     'T@@ ô@@ i l@@ à V@@ i@@ n@@ A@@ I R@@ e@@ s@@ e@@ a@@ r@@ c@@ h'.split()
     __lowerCAmelCase							     =     tokenizer.tokenize(lowerCAmelCase_					)
     print(lowerCAmelCase_					)
     self.assertListEqual(lowerCAmelCase_ ,  lowerCAmelCase_					)

     __lowerCAmelCase							     =     tokens + [tokenizer.unk_token]

     __lowerCAmelCase							     =     [4, 3, 5, 3, 3, 3, 3, 3, 3, 6, 7, 9, 3, 9, 3, 3, 3, 3, 3]
     self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCAmelCase_					) ,  lowerCAmelCase_					)







from collections.abc import Sequence

def   a_   (			lowerCAmelCase_				:      Sequence[float],     lowerCAmelCase_				:      bool = False     ):
   if not arr:
      return 0

   __lowerCAmelCase							     =     0 if allow_empty_subarrays else float('-inf'     )
   __lowerCAmelCase							     =     0.0
   for num in arr:
      __lowerCAmelCase							     =     max(0 if allow_empty_subarrays else num,     curr_sum + num     )
      __lowerCAmelCase							     =     max(lowerCAmelCase_,     lowerCAmelCase_     )

   return max_sum


if __name__ == "__main__":
     from doctest import testmod

     testmod()

     _snake_case  :   Optional[Any]						   =  [-2, 1, -3, 4, -1, 2, 1, -5, 4]
     print(F"""{max_subarray_sum(nums) = }""")

