



'''simple docstring'''






import os
import unittest

from transformers import LxmertTokenizer, LxmertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class 							SCREAMING_SNAKE_CASE(				UpperCAmelCase_				,						unittest.TestCase     ):







	"""simple docstring"""






	lowerCamelCase__     					=			LxmertTokenizer
	lowerCamelCase__     					=			LxmertTokenizerFast
	lowerCamelCase__     					=			True
	lowerCamelCase__     					=			True







	def 	A      (		self     :	List[Any]						)     ->						Union[str, Any]:
								super().setUp()

								UpperCAmelCase					:			Tuple									=						[
								    """[UNK]""",
								    """[CLS]""",
								    """[SEP]""",
								    """want""",
								    """##want""",
								    """##ed""",
								    """wa""",
								    """un""",
								    """runn""",
								    """##ing""",
								    """,""",
								    """low""",
								    """lowest""",
								]
								UpperCAmelCase					:			str									=						os.path.join(self.tmpdirname						,     VOCAB_FILES_NAMES['''vocab_file''']						)
								with open(self.vocab_file						,     '''w'''						,     encoding='''utf-8'''						) as vocab_writer:
															vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]						)						)







	def 	A      (		self     :	List[str]						,     __snake_case     :	int						)     ->						List[str]:
								UpperCAmelCase					:			Optional[Any]									=						"""UNwant\u00E9d,running"""
								UpperCAmelCase					:			Union[str, Any]									=						"""unwanted, running"""
								return input_text, output_text







	def 	A      (		self     :	Any						)     ->						Union[str, Any]:
								UpperCAmelCase					:			Dict									=						self.tokenizer_class(self.vocab_file						)

								UpperCAmelCase					:			List[Any]									=						tokenizer.tokenize('''UNwant\u00E9d,running'''						)
								self.assertListEqual(SCREAMING_SNAKE_CASE_						,     ['''un''', '''##want''', '''##ed''', ''',''', '''runn''', '''##ing''']						)
								self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_						)						,     [7, 4, 5, 10, 8, 9]						)







	def 	A      (		self     :	List[Any]						)     ->						Union[str, Any]:




								if not self.test_rust_tokenizer:
															return

								UpperCAmelCase					:			Tuple									=						self.get_tokenizer()
								UpperCAmelCase					:			Dict									=						self.get_rust_tokenizer()

								UpperCAmelCase					:			List[Any]									=						"""I was born in 92000, and this is falsé."""

								UpperCAmelCase					:			List[str]									=						tokenizer.tokenize(SCREAMING_SNAKE_CASE_						)
								UpperCAmelCase					:			Any									=						rust_tokenizer.tokenize(SCREAMING_SNAKE_CASE_						)
								self.assertListEqual(SCREAMING_SNAKE_CASE_						,     SCREAMING_SNAKE_CASE_						)

								UpperCAmelCase					:			int									=						tokenizer.encode(SCREAMING_SNAKE_CASE_						,     add_special_tokens=SCREAMING_SNAKE_CASE_						)
								UpperCAmelCase					:			Union[str, Any]									=						rust_tokenizer.encode(SCREAMING_SNAKE_CASE_						,     add_special_tokens=SCREAMING_SNAKE_CASE_						)
								self.assertListEqual(SCREAMING_SNAKE_CASE_						,     SCREAMING_SNAKE_CASE_						)

								UpperCAmelCase					:			Tuple									=						self.get_rust_tokenizer()
								UpperCAmelCase					:			List[Any]									=						tokenizer.encode(SCREAMING_SNAKE_CASE_						)
								UpperCAmelCase					:			Dict									=						rust_tokenizer.encode(SCREAMING_SNAKE_CASE_						)
								self.assertListEqual(SCREAMING_SNAKE_CASE_						,     SCREAMING_SNAKE_CASE_						)







# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


lowerCamelCase__     :		Optional[int]        = [
    """EAGER""",
    """AOT_EAGER""",
    """INDUCTOR""",
    """NVFUSER""",
    """AOT_NVFUSER""",
    """AOT_CUDAGRAPHS""",
    """OFI""",
    """FX2TRT""",
    """ONNXRT""",
    """IPEX""",
]

def 		UpperCamelCase						(   lowercase_			,			lowercase_=None			,			lowercase_=None			,			lowercase_=None )		->						Optional[Any]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   True
  while ask_again:
    lowercase__	: Tuple     		=   input(lowercase_ )
    try:
      if default is not None and len(lowercase_ ) == 0:
        return default
      return convert_value(lowercase_ ) if convert_value is not None else result
    except Exception:
      if error_message is not None:
        print(lowercase_ )

def 		UpperCamelCase						(   lowercase_			,			lowercase_=[]			,			lowercase_=None			,			lowercase_=0 )		->						Union[str, Any]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   BulletMenu(lowercase_			,			lowercase_ )
  lowercase__	: Any     		=   menu.run(default_choice=lowercase_ )
  return convert_value(lowercase_ ) if convert_value is not None else result

def 		UpperCamelCase						(   lowercase_ )		->						str:


  '''simple docstring'''






  lowercase__	: Union[str, Any]     		=   int(lowercase_ )
  return ComputeEnvironment(["""LOCAL_MACHINE""", """AMAZON_SAGEMAKER"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






  lowercase__	: List[str]     		=   int(lowercase_ )
  return DistributedType(["""NO""", """MULTI_CPU""", """MULTI_XPU""", """MULTI_GPU""", """MULTI_NPU""", """TPU"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						str:


  '''simple docstring'''






  lowercase__	: str     		=   int(lowercase_ )
  return DynamoBackend(DYNAMO_BACKENDS[value] ).value

def 		UpperCamelCase						(   lowercase_ )		->						Union[str, Any]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   int(lowercase_ )
  return PrecisionType(["""no""", """fp16""", """bf16""", """fp8"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   int(lowercase_ )
  return SageMakerDistributedType(["""NO""", """DATA_PARALLEL""", """MODEL_PARALLEL"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






  return {"yes": True, "no": False}[value.lower()]



class    _snake_case (						argparse.RawDescriptionHelpFormatter				):


 def   lowercase__  (       self       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__	: int     		=   super()._format_usage(SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_)
   lowercase__	: Optional[Any]     		=   usage.replace("""<command> [<args>] """       ,	"""""")
   return usage






