





'''simple docstring'''


import json
import os
import unittest

from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer

from ...test_tokenization_common import TokenizerTesterMixin
class 				a_       (    _lowerCAmelCase     ,						unittest.TestCase							):
     __A								=      CTRLTokenizer
     __A								=      False
     __A								=      False





     def 							lowercase__				(			self		: List[str]						):





        """simple docstring"""




        super().setUp()

        # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
        lowercase_      :Optional[int]         =			["adapt", "re@@", "a@@", "apt", "c@@", "t", "<unk>"]
        lowercase_      :Optional[Any]         =			dict(zip(lowercase     ,				range(len(lowercase						)						)						)						)
        lowercase_      :Optional[int]         =			["#version: 0.2", "a p", "ap t</w>", "r e", "a d", "ad apt</w>", ""]
        lowercase_      :Tuple         =			{"unk_token": "<unk>"}

        lowercase_      :List[str]         =			os.path.join(self.tmpdirname     ,				VOCAB_FILES_NAMES["vocab_file"]						)
        lowercase_      :Tuple         =			os.path.join(self.tmpdirname     ,				VOCAB_FILES_NAMES["merges_file"]						)
        with open(self.vocab_file     ,				"w"     ,				encoding="utf-8"						) as fp:
           fp.write(json.dumps(lowercase						) + "\n"						)
        with open(self.merges_file     ,				"w"     ,				encoding="utf-8"						) as fp:
           fp.write("\n".join(lowercase						)						)





     def 							lowercase__				(			self		: int     ,				**lowercase		: str						):





        """simple docstring"""




        kwargs.update(self.special_tokens_map						)
        return CTRLTokenizer.from_pretrained(self.tmpdirname     ,				**lowercase						)





     def 							lowercase__				(			self		: List[str]     ,				lowercase		: Dict						):





        """simple docstring"""




        lowercase_      :Union[str, Any]         =			"adapt react readapt apt"
        lowercase_      :List[Any]         =			"adapt react readapt apt"
        return input_text, output_text







     def 							lowercase__				(			self		: Dict						):





        """simple docstring"""




        lowercase_      :Dict         =			CTRLTokenizer(self.vocab_file     ,				self.merges_file     ,				**self.special_tokens_map						)
        lowercase_      :List[Any]         =			"adapt react readapt apt"
        lowercase_      :str         =			"adapt re@@ a@@ c@@ t re@@ adapt apt".split()
        lowercase_      :List[str]         =			tokenizer.tokenize(lowercase						)
        self.assertListEqual(lowercase     ,				lowercase						)

        lowercase_      :str         =			tokens + [tokenizer.unk_token]

        lowercase_      :List[str]         =			[0, 1, 2, 4, 5, 1, 0, 3, 6]
        self.assertListEqual(tokenizer.convert_tokens_to_ids(lowercase						)     ,				lowercase						)









'''simple docstring'''


import numpy as np
def 							UpperCAmelCase_  (						__lowerCamelCase : str     ,__lowerCamelCase : Optional[Any]     ,__lowerCamelCase : int     ,__lowerCamelCase : List[str]     ,__lowerCamelCase : List[Any]			):
   lowercase_      :Dict         =			int(np.ceil((x_end - xa) / h			)			)
   lowercase_      :Optional[int]         =			np.zeros((n + 1,)			)
   lowercase_      :Tuple         =			ya
   lowercase_      :List[str]         =			xa

   for k in range(__lowerCamelCase			):
      lowercase_      :Any         =			f(__lowerCamelCase     ,y[k]			)
      lowercase_      :Optional[Any]         =			f(x + 0.5 * h     ,y[k] + 0.5 * h * ka			)
      lowercase_      :Optional[Any]         =			f(x + 0.5 * h     ,y[k] + 0.5 * h * ka			)
      lowercase_      :Any         =			f(x + h     ,y[k] + h * ka			)
      lowercase_      :Tuple         =			y[k] + (1 / 6) * h * (ka + 2 * ka + 2 * ka + ka)
      x += h

   return y


if __name__ == "__main__":
 import doctest

 doctest.testmod()


