



"""simple docstring"""

import argparse
import os


A_	:						List[Any]				=			{
    """pytorch""": {
        """1.13""": {
            """torch""": """1.13.1""",
            """torchvision""": """0.14.1""",
            """torchaudio""": """0.13.1""",
            """python""": 3.9,
            """cuda""": """cu116""",
            """install""": (
                """python3 -m pip install --no-cache-dir -U torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1"""
                """ --extra-index-url https://download.pytorch.org/whl/cu116"""
            ),
            """base_image""": """nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04""",
        },
        """1.12""": {
            """torch""": """1.12.1""",
            """torchvision""": """0.13.1""",
            """torchaudio""": """0.12.1""",
            """python""": 3.9,
            """cuda""": """cu113""",
            """install""": (
                """python3 -m pip install --no-cache-dir -U torch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1"""
                """ --extra-index-url https://download.pytorch.org/whl/cu113"""
            ),
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """1.11""": {
            """torch""": """1.11.0""",
            """torchvision""": """0.12.0""",
            """torchaudio""": """0.11.0""",
            """python""": 3.9,
            """cuda""": """cu113""",
            """install""": (
                """python3 -m pip install --no-cache-dir -U torch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0"""
                """ --extra-index-url https://download.pytorch.org/whl/cu113"""
            ),
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """1.10""": {
            """torch""": """1.10.2""",
            """torchvision""": """0.11.3""",
            """torchaudio""": """0.10.2""",
            """python""": 3.9,
            """cuda""": """cu113""",
            """install""": (
                """python3 -m pip install --no-cache-dir -U torch==1.10.2 torchvision==0.11.3 torchaudio==0.10.2"""
                """ --extra-index-url https://download.pytorch.org/whl/cu113"""
            ),
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        # torchaudio < 0.10 has no CUDA-enabled binary distributions
        """1.9""": {
            """torch""": """1.9.1""",
            """torchvision""": """0.10.1""",
            """torchaudio""": """0.9.1""",
            """python""": 3.9,
            """cuda""": """cu111""",
            """install""": (
                """python3 -m pip install --no-cache-dir -U torch==1.9.1 torchvision==0.10.1 torchaudio==0.9.1"""
                """ --extra-index-url https://download.pytorch.org/whl/cu111"""
            ),
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
    },
    """tensorflow""": {
        """2.11""": {
            """tensorflow""": """2.11.1""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.11.1""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """2.10""": {
            """tensorflow""": """2.10.1""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.10.1""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """2.9""": {
            """tensorflow""": """2.9.3""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.9.3""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """2.8""": {
            """tensorflow""": """2.8.2""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.8.2""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """2.7""": {
            """tensorflow""": """2.7.3""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.7.3""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """2.6""": {
            """tensorflow""": """2.6.5""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.6.5""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
        """2.5""": {
            """tensorflow""": """2.5.3""",
            """install""": """python3 -m pip install --no-cache-dir -U tensorflow==2.5.3""",
            """base_image""": """nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04""",
        },
    },
}


if __name__ == "__main__":
							A_	:						Union[str, Any]				=			argparse.ArgumentParser('Choose the framework and version to install')
							parser.add_argument(
							    '--framework', help='The framework to install. Should be `torch` or `tensorflow`', type=str, required=True
							)
							parser.add_argument('--version', help='The version of the framework to install.', type=str, required=True)
							A_	:						int				=			parser.parse_args()

							A_	:						Any				=			past_versions_testing[args.framework][args.version]

							os.system(f'''echo "export INSTALL_CMD=\'{info["install"]}\'" >> ~/.profile''')
							print(f'''echo "export INSTALL_CMD=\'{info["install"]}\'" >> ~/.profile''')

							A_	:						Union[str, Any]				=			""""""
							if args.framework == "pytorch":
														A_	:						Tuple				=			info["""cuda"""]
							os.system(f'''echo \"export CUDA=\'{cuda}\'\" >> ~/.profile''')
							print(f'''echo \"export CUDA=\'{cuda}\'\" >> ~/.profile''')











"""simple docstring"""

import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_longformer import LongformerTokenizer


A_	:						Tuple				=			logging.get_logger(__name__)

A_	:						Optional[Any]				=			{'vocab_file': 'vocab.json', 'merges_file': 'merges.txt', 'tokenizer_file': 'tokenizer.json'}

A_	:						Any				=			{
    'vocab_file': {
        'allenai/longformer-base-4096': 'https://huggingface.co/allenai/longformer-base-4096/resolve/main/vocab.json',
        'allenai/longformer-large-4096': (
            'https://huggingface.co/allenai/longformer-large-4096/resolve/main/vocab.json'
        ),
        'allenai/longformer-large-4096-finetuned-triviaqa': (
            'https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/vocab.json'
        ),
        'allenai/longformer-base-4096-extra.pos.embd.only': (
            'https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/vocab.json'
        ),
        'allenai/longformer-large-4096-extra.pos.embd.only': (
            'https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/vocab.json'
        ),
    },
    'merges_file': {
        'allenai/longformer-base-4096': 'https://huggingface.co/allenai/longformer-base-4096/resolve/main/merges.txt',
        'allenai/longformer-large-4096': (
            'https://huggingface.co/allenai/longformer-large-4096/resolve/main/merges.txt'
        ),
        'allenai/longformer-large-4096-finetuned-triviaqa': (
            'https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/merges.txt'
        ),
        'allenai/longformer-base-4096-extra.pos.embd.only': (
            'https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/merges.txt'
        ),
        'allenai/longformer-large-4096-extra.pos.embd.only': (
            'https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/merges.txt'
        ),
    },
    'tokenizer_file': {
        'allenai/longformer-base-4096': (
            'https://huggingface.co/allenai/longformer-base-4096/resolve/main/tokenizer.json'
        ),
        'allenai/longformer-large-4096': (
            'https://huggingface.co/allenai/longformer-large-4096/resolve/main/tokenizer.json'
        ),
        'allenai/longformer-large-4096-finetuned-triviaqa': (
            'https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/tokenizer.json'
        ),
        'allenai/longformer-base-4096-extra.pos.embd.only': (
            'https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/tokenizer.json'
        ),
        'allenai/longformer-large-4096-extra.pos.embd.only': (
            'https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/tokenizer.json'
        ),
    },
}

A_	:						int				=			{
    'allenai/longformer-base-4096': 4096,
    'allenai/longformer-large-4096': 4096,
    'allenai/longformer-large-4096-finetuned-triviaqa': 4096,
    'allenai/longformer-base-4096-extra.pos.embd.only': 4096,
    'allenai/longformer-large-4096-extra.pos.embd.only': 4096,
}
class 						lowerCAmelCase__	(  _lowerCamelCase   ):


	'''simple docstring'''







	_SCREAMING_SNAKE_CASE  :		Optional[int]     	=   VOCAB_FILES_NAMES
	_SCREAMING_SNAKE_CASE  :		List[Any]     	=   PRETRAINED_VOCAB_FILES_MAP
	_SCREAMING_SNAKE_CASE  :		int     	=   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	_SCREAMING_SNAKE_CASE  :		Union[str, Any]     	=   ['''input_ids''', '''attention_mask''']
	_SCREAMING_SNAKE_CASE  :		Optional[int]     	=   LongformerTokenizer





	def __init__(			self							:					Optional[Any]    ,					_SCREAMING_SNAKE_CASE							:					Tuple=None    ,					_SCREAMING_SNAKE_CASE							:					Optional[Any]=None    ,					_SCREAMING_SNAKE_CASE							:					Any=None    ,					_SCREAMING_SNAKE_CASE							:					Union[str, Any]="replace"    ,					_SCREAMING_SNAKE_CASE							:					Optional[Any]="<s>"    ,					_SCREAMING_SNAKE_CASE							:					Dict="</s>"    ,					_SCREAMING_SNAKE_CASE							:					int="</s>"    ,					_SCREAMING_SNAKE_CASE							:					List[Any]="<s>"    ,					_SCREAMING_SNAKE_CASE							:					int="<unk>"    ,					_SCREAMING_SNAKE_CASE							:					Any="<pad>"    ,					_SCREAMING_SNAKE_CASE							:					Optional[int]="<mask>"    ,					_SCREAMING_SNAKE_CASE							:					Optional[Any]=False    ,					_SCREAMING_SNAKE_CASE							:					Dict=True    ,					**_SCREAMING_SNAKE_CASE							:					Tuple    ,					)	->  Optional[int]:





					"""simple docstring"""


					super().__init__(
					    _SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE    ,					tokenizer_file=_SCREAMING_SNAKE_CASE    ,					errors=_SCREAMING_SNAKE_CASE    ,					bos_token=_SCREAMING_SNAKE_CASE    ,					eos_token=_SCREAMING_SNAKE_CASE    ,					sep_token=_SCREAMING_SNAKE_CASE    ,					cls_token=_SCREAMING_SNAKE_CASE    ,					unk_token=_SCREAMING_SNAKE_CASE    ,					pad_token=_SCREAMING_SNAKE_CASE    ,					mask_token=_SCREAMING_SNAKE_CASE    ,					add_prefix_space=_SCREAMING_SNAKE_CASE    ,					trim_offsets=_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE    ,					)

					SCREAMING_SNAKE_CASE	:       List[str] 							=    json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()						)
					if pre_tok_state.get('add_prefix_space'    ,					_SCREAMING_SNAKE_CASE						) != add_prefix_space:
									SCREAMING_SNAKE_CASE	:       Dict 							=    getattr(_SCREAMING_SNAKE_CASE    ,					pre_tok_state.pop('type'						)						)
									SCREAMING_SNAKE_CASE	:       Any 							=    add_prefix_space
									SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    pre_tok_class(**_SCREAMING_SNAKE_CASE						)

					SCREAMING_SNAKE_CASE	:       Dict 							=    add_prefix_space

					SCREAMING_SNAKE_CASE	:       List[str] 							=    'post_processor'
					SCREAMING_SNAKE_CASE	:       str 							=    getattr(self.backend_tokenizer    ,					_SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE						)
					if tokenizer_component_instance:
									SCREAMING_SNAKE_CASE	:       Any 							=    json.loads(tokenizer_component_instance.__getstate__()						)

									# The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
									if "sep" in state:
													SCREAMING_SNAKE_CASE	:       Optional[int] 							=    tuple(state['sep']						)
									if "cls" in state:
													SCREAMING_SNAKE_CASE	:       Tuple 							=    tuple(state['cls']						)

									SCREAMING_SNAKE_CASE	:       List[str] 							=    False

									if state.get('add_prefix_space'    ,					_SCREAMING_SNAKE_CASE						) != add_prefix_space:
													SCREAMING_SNAKE_CASE	:       Dict 							=    add_prefix_space
													SCREAMING_SNAKE_CASE	:       Dict 							=    True

									if state.get('trim_offsets'    ,					_SCREAMING_SNAKE_CASE						) != trim_offsets:
													SCREAMING_SNAKE_CASE	:       str 							=    trim_offsets
													SCREAMING_SNAKE_CASE	:       int 							=    True

									if changes_to_apply:
													SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    getattr(_SCREAMING_SNAKE_CASE    ,					state.pop('type'						)						)
													SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    component_class(**_SCREAMING_SNAKE_CASE						)
													setattr(self.backend_tokenizer    ,					_SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE						)





	@property
	def  _lowerCAmelCase    (			self							:					Dict						)	->  str:





					"""simple docstring"""


					if self._mask_token is None:
									if self.verbose:
													logger.error('Using mask_token, but it is not set yet.'						)
									return None
					return str(self._mask_token						)





	@mask_token.setter
	def  _lowerCAmelCase    (			self							:					Tuple    ,					_SCREAMING_SNAKE_CASE							:					str						)	->  Union[str, Any]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Dict 							=    AddedToken(_SCREAMING_SNAKE_CASE    ,					lstrip=_SCREAMING_SNAKE_CASE    ,					rstrip=_SCREAMING_SNAKE_CASE						) if isinstance(_SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE						) else value
					SCREAMING_SNAKE_CASE	:       Any 							=    value





	def  _lowerCAmelCase    (			self							:					Optional[Any]    ,					*_SCREAMING_SNAKE_CASE							:					Optional[Any]    ,					**_SCREAMING_SNAKE_CASE							:					int						)	->  BatchEncoding:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    kwargs.get('is_split_into_words'    ,					_SCREAMING_SNAKE_CASE						)
					assert self.add_prefix_space or not is_split_into_words, (
					    f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
					    "to use it with pretokenized inputs."
					)

					return super()._batch_encode_plus(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE						)





	def  _lowerCAmelCase    (			self							:					List[Any]    ,					*_SCREAMING_SNAKE_CASE							:					Optional[Any]    ,					**_SCREAMING_SNAKE_CASE							:					str						)	->  BatchEncoding:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       List[Any] 							=    kwargs.get('is_split_into_words'    ,					_SCREAMING_SNAKE_CASE						)

					assert self.add_prefix_space or not is_split_into_words, (
					    f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
					    "to use it with pretokenized inputs."
					)

					return super()._encode_plus(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE						)





	def  _lowerCAmelCase    (			self							:					Any    ,					_SCREAMING_SNAKE_CASE							:					str    ,					_SCREAMING_SNAKE_CASE							:					Optional[str] = None						)	->  Tuple[str]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Optional[int] 							=    self._tokenizer.model.save(_SCREAMING_SNAKE_CASE    ,					name=_SCREAMING_SNAKE_CASE						)
					return tuple(_SCREAMING_SNAKE_CASE						)





	def  _lowerCAmelCase    (			self							:					Tuple    ,					_SCREAMING_SNAKE_CASE							:					List[str]    ,					_SCREAMING_SNAKE_CASE							:					Dict=None						)	->  Union[str, Any]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Optional[int] 							=    [self.bos_token_id] + token_ids_a + [self.eos_token_id]
					if token_ids_a is None:
									return output

					return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]







	def  _lowerCAmelCase    (			self							:					Dict    ,					_SCREAMING_SNAKE_CASE							:					List[int]    ,					_SCREAMING_SNAKE_CASE							:					Optional[List[int]] = None						)	->  List[int]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Tuple 							=    [self.sep_token_id]
					SCREAMING_SNAKE_CASE	:       Optional[int] 							=    [self.cls_token_id]

					if token_ids_a is None:
									return len(cls + token_ids_a + sep						) * [0]
					return len(cls + token_ids_a + sep + sep + token_ids_a + sep						) * [0]





