
"""simple docstring"""

import json
import os
import unittest

from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer
from transformers.testing_utils import slow

from ...test_tokenization_common import TokenizerTesterMixin

class __lowerCAmelCase	(   __SCREAMING_SNAKE_CASE    ,						unittest.TestCase    ):
     lowercase		     =		XLMTokenizer
     lowercase		     =		False





     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      super().setUp()

      # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
      __UpperCamelCase       						= [
          'l',
          'o',
          'w',
          'e',
          'r',
          's',
          't',
          'i',
          'd',
          'n',
          'w</w>',
          'r</w>',
          't</w>',
          'lo',
          'low',
          'er</w>',
          'low</w>',
          'lowest</w>',
          'newer</w>',
          'wider</w>',
          '<unk>',
      ]
      __UpperCamelCase       						= dict(zip(__UpperCAmelCase			,  range(len(__UpperCAmelCase   )   )   )   )
      __UpperCamelCase       						= ['l o 123', 'lo w 1456', 'e r</w> 1789', '']

      __UpperCamelCase       						= os.path.join(self.tmpdirname			,  VOCAB_FILES_NAMES['vocab_file']   )
      __UpperCamelCase       						= os.path.join(self.tmpdirname			,  VOCAB_FILES_NAMES['merges_file']   )
      with open(self.vocab_file			,  'w'   ) as fp:
       fp.write(json.dumps(__UpperCAmelCase   )   )
      with open(self.merges_file			,  'w'   ) as fp:
       fp.write('\n'.join(__UpperCAmelCase   )   )





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase   ):

      '''simple docstring'''




      __UpperCamelCase       						= 'lower newer'
      __UpperCamelCase       						= 'lower newer'
      return input_text, output_text





     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      __UpperCamelCase       						= XLMTokenizer(self.vocab_file			,  self.merges_file   )

      __UpperCamelCase       						= 'lower'
      __UpperCamelCase       						= ['low', 'er</w>']
      __UpperCamelCase       						= tokenizer.tokenize(__UpperCAmelCase   )
      self.assertListEqual(__UpperCAmelCase			,  __UpperCAmelCase   )

      __UpperCamelCase       						= tokens + ['<unk>']
      __UpperCamelCase       						= [14, 15, 20]
      self.assertListEqual(tokenizer.convert_tokens_to_ids(__UpperCAmelCase   )			,  __UpperCAmelCase   )







     @slow
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      __UpperCamelCase       						= XLMTokenizer.from_pretrained('xlm-mlm-en-2048'   )

      __UpperCamelCase       						= tokenizer.encode('sequence builders'			,  add_special_tokens=__UpperCAmelCase   )
      __UpperCamelCase       						= tokenizer.encode('multi-sequence build'			,  add_special_tokens=__UpperCAmelCase   )

      __UpperCamelCase       						= tokenizer.build_inputs_with_special_tokens(__UpperCAmelCase   )
      __UpperCamelCase       						= tokenizer.build_inputs_with_special_tokens(__UpperCAmelCase			,  __UpperCAmelCase   )

      assert encoded_sentence == [0] + text + [1]
      assert encoded_pair == [0] + text + [1] + text_a + [1]





"""simple docstring"""

def 							A		(       snake_case   :int       ,      snake_case   :int	)   ->			int:
 return int(input_a == input_a == 0	)






def 							A		(       )   ->			None:
 print('Truth Table of NOR Gate:'	)
 print('|   Input 1   |  Input 2  | Output |'	)
 print(f'|      0      |    0      |  {nor_gate(0       ,      0	)}     |'	)
 print(f'|      0      |    1      |  {nor_gate(0       ,      1	)}     |'	)
 print(f'|      1      |    0      |  {nor_gate(1       ,      0	)}     |'	)
 print(f'|      1      |    1      |  {nor_gate(1       ,      1	)}     |'	)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      main()



