





import os
import unittest

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

from ...test_tokenization_common import TokenizerTesterMixin







class       __A							(   lowerCamelCase__			,unittest.TestCase	):




      """simple docstring"""







      UpperCAmelCase__							=   PhobertTokenizer
      UpperCAmelCase__							=   False


      def 					__snake_case      (		self):



             """simple docstring"""





             super().setUp()

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

             _lowerCamelCase				:  Union[str, Any]						=		os.path.join(self.tmpdirname   ,				VOCAB_FILES_NAMES['''vocab_file'''])
             _lowerCamelCase				:  Dict						=		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(a__))


      def 					__snake_case      (		self   ,				**a__):



             """simple docstring"""





             kwargs.update(self.special_tokens_map)
             return PhobertTokenizer.from_pretrained(self.tmpdirname   ,				**a__)


      def 					__snake_case      (		self   ,				a__):



             """simple docstring"""





             _lowerCamelCase				:  str						=		'''Tôi là VinAI Research'''
             _lowerCamelCase				:  List[Any]						=		'''T<unk> i <unk> <unk> <unk> <unk> <unk> <unk> I Re<unk> e<unk> <unk> <unk> <unk>'''
             return input_text, output_text



      def 					__snake_case      (		self):



             """simple docstring"""





             _lowerCamelCase				:  Optional[Any]						=		PhobertTokenizer(self.vocab_file   ,				self.merges_file   ,				**self.special_tokens_map)
             _lowerCamelCase				:  Tuple						=		'''Tôi là VinAI Research'''
             _lowerCamelCase				:  str						=		'''T@@ ô@@ i l@@ à V@@ i@@ n@@ A@@ I R@@ e@@ s@@ e@@ a@@ r@@ c@@ h'''.split()
             _lowerCamelCase				:  str						=		tokenizer.tokenize(a__)
             print(a__)
             self.assertListEqual(a__   ,				a__)

             _lowerCamelCase				:  Tuple						=		tokens + [tokenizer.unk_token]

             _lowerCamelCase				:  Optional[int]						=		[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(a__)   ,				a__)








import doctest
from collections import deque

import numpy as np







class       __A							:




      """simple docstring"""







      def __init__(		self):



             """simple docstring"""





             _lowerCamelCase				:  Any						=		[2, 1, 2, -1]
             _lowerCamelCase				:  Optional[int]						=		[1, 2, 3, 4]



      def 					__snake_case      (		self):



             """simple docstring"""





             _lowerCamelCase				:  Optional[int]						=		len(self.first_signal)
             _lowerCamelCase				:  str						=		len(self.second_signal)

             _lowerCamelCase				:  str						=		max(a__   ,				a__)

             # create a zero matrix of max_length x max_length
             _lowerCamelCase				:  Optional[Any]						=		[[0] * max_length for i in range(a__)]

             # fills the smaller signal with zeros to make both signals of same length
             if length_first_signal < length_second_signal:
                    self.first_signal += [0] * (max_length - length_first_signal)
             elif length_first_signal > length_second_signal:
                    self.second_signal += [0] * (max_length - length_second_signal)
             for i in range(a__):
                    _lowerCamelCase				:  Optional[Any]						=		deque(self.second_signal)
                    rotated_signal.rotate(a__)
                    for j, item in enumerate(a__):
                           matrix[i][j] += item

        # multiply the matrix with the first signal
             _lowerCamelCase				:  List[Any]						=		np.matmul(np.transpose(a__)   ,				np.transpose(self.first_signal))

             # rounding-off to two decimal places
             return [round(a__   ,				2) for i in final_signal]


if __name__ == "__main__":
       doctest.testmod()

