

import json
import os
from functools import lru_cache
from typing import List, Optional, Tuple

import regex as re

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


_a:    List[str] 							=			logging.get_logger(__name__)


_a:    Union[str, Any] 							=			{"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt"""}

_a:    Union[str, 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"""
        ),
    },
}

_a:    List[Any] 							=			{
    """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,
}



@lru_cache()
# Copied from transformers.models.roberta.tokenization_roberta.bytes_to_unicode
def       __lowerCAmelCase      (						):
	UpperCAmelCase_       				=			(
	    list(range(ord("!"    )       ,     ord("~"    ) + 1    )    ) + list(range(ord("¡"    )       ,     ord("¬"    ) + 1    )    ) + list(range(ord("®"    )       ,     ord("ÿ"    ) + 1    )    )
	)
	UpperCAmelCase_       				=			bs[:]
	UpperCAmelCase_       				=			0
	for b in range(2**8    ):
		if b not in bs:
			bs.append(A    )
			cs.append(2**8 + n    )
			n += 1
	UpperCAmelCase_       				=			[chr(A    ) for n in cs]
	return dict(zip(A       ,     A    )    )



def       __lowerCAmelCase      (						A    ):
	UpperCAmelCase_       				=			set()
	UpperCAmelCase_       				=			word[0]
	for char in word[1:]:
		pairs.add((prev_char, char)    )
		UpperCAmelCase_       				=			char
	return pairs




class 						__UpperCamelCase    (					lowercase						):
	SCREAMING_SNAKE_CASE__    				=     VOCAB_FILES_NAMES
	SCREAMING_SNAKE_CASE__    				=     PRETRAINED_VOCAB_FILES_MAP
	SCREAMING_SNAKE_CASE__    				=     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	SCREAMING_SNAKE_CASE__    				=     ['input_ids', 'attention_mask']




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


		'''simple docstring'''







		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else bos_token
		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else eos_token
		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else sep_token
		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else cls_token
		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else unk_token
		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else pad_token

		# Mask token behave like a normal word, i.e. include the space before it
		UpperCAmelCase_       				=			AddedToken(lowerCAmelCase		,	lstrip=lowerCAmelCase		,	rstrip=lowerCAmelCase							) if isinstance(lowerCAmelCase		,	lowerCAmelCase							) else mask_token

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

		with open(lowerCAmelCase		,	encoding="utf-8"							) as vocab_handle:
			UpperCAmelCase_       				=			json.load(lowerCAmelCase							)
		UpperCAmelCase_       				=			{v: k for k, v in self.encoder.items()}
		UpperCAmelCase_       				=			errors  # how to handle errors in decoding
		UpperCAmelCase_       				=			bytes_to_unicode()
		UpperCAmelCase_       				=			{v: k for k, v in self.byte_encoder.items()}
		with open(lowerCAmelCase		,	encoding="utf-8"							) as merges_handle:
			UpperCAmelCase_       				=			merges_handle.read().split("\n"							)[1:-1]
		UpperCAmelCase_       				=			[tuple(merge.split()							) for merge in bpe_merges]
		UpperCAmelCase_       				=			dict(zip(lowerCAmelCase		,	range(len(lowerCAmelCase							)							)							)							)
		UpperCAmelCase_       				=			{}
		UpperCAmelCase_       				=			add_prefix_space

		# Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
		UpperCAmelCase_       				=			re.compile(R"'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"							)




	@property
	def       __A					(		self	:						Dict							):


		'''simple docstring'''







		return len(self.encoder							)




	def       __A					(		self	:						Tuple							):


		'''simple docstring'''







		return dict(self.encoder		,	**self.added_tokens_encoder							)




	def       __A					(		self	:						Dict		,	lowerCAmelCase	:						Optional[Any]							):


		'''simple docstring'''







		if token in self.cache:
			return self.cache[token]
		UpperCAmelCase_       				=			tuple(lowerCAmelCase							)
		UpperCAmelCase_       				=			get_pairs(lowerCAmelCase							)

		if not pairs:
			return token

		while True:
			UpperCAmelCase_       				=			min(lowerCAmelCase		,	key=lambda lowerCAmelCase							: self.bpe_ranks.get(lowerCAmelCase		,	float("inf"							)							)							)
			if bigram not in self.bpe_ranks:
				break
			UpperCAmelCase_				,   UpperCAmelCase_       				=			bigram
			UpperCAmelCase_       				=			[]
			UpperCAmelCase_       				=			0
			while i < len(lowerCAmelCase							):
				try:
					UpperCAmelCase_       				=			word.index(lowerCAmelCase		,	lowerCAmelCase							)
				except ValueError:
					new_word.extend(word[i:]							)
					break
				else:
					new_word.extend(word[i:j]							)
					UpperCAmelCase_       				=			j

				if word[i] == first and i < len(lowerCAmelCase							) - 1 and word[i + 1] == second:
					new_word.append(first + second							)
					i += 2
				else:
					new_word.append(word[i]							)
					i += 1
			UpperCAmelCase_       				=			tuple(lowerCAmelCase							)
			UpperCAmelCase_       				=			new_word
			if len(lowerCAmelCase							) == 1:
				break
			else:
				UpperCAmelCase_       				=			get_pairs(lowerCAmelCase							)
		UpperCAmelCase_       				=			" ".join(lowerCAmelCase							)
		UpperCAmelCase_       				=			word
		return word




	def       __A					(		self	:						str		,	lowerCAmelCase	:						int							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		for token in re.findall(self.pat		,	lowerCAmelCase							):
			UpperCAmelCase_       				=			"".join(
			    self.byte_encoder[b] for b in token.encode("utf-8"							)							)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
			bpe_tokens.extend(bpe_token for bpe_token in self.bpe(lowerCAmelCase							).split(" "							)							)
		return bpe_tokens




	def       __A					(		self	:						Tuple		,	lowerCAmelCase	:						int							):


		'''simple docstring'''







		return self.encoder.get(lowerCAmelCase		,	self.encoder.get(self.unk_token							)							)




	def       __A					(		self	:						List[str]		,	lowerCAmelCase	:						Any							):


		'''simple docstring'''







		return self.decoder.get(lowerCAmelCase							)




	def       __A					(		self	:						int		,	lowerCAmelCase	:						List[str]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			"".join(lowerCAmelCase							)
		UpperCAmelCase_       				=			bytearray([self.byte_decoder[c] for c in text]							).decode("utf-8"		,	errors=self.errors							)
		return text




	def       __A					(		self	:						str		,	lowerCAmelCase	:						str		,	lowerCAmelCase	:						Optional[str] = None							):


		'''simple docstring'''







		if not os.path.isdir(lowerCAmelCase							):
			logger.error(F"Vocabulary path ({save_directory}) should be a directory"							)
			return
		UpperCAmelCase_       				=			os.path.join(
		    lowerCAmelCase		,	(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]							)
		UpperCAmelCase_       				=			os.path.join(
		    lowerCAmelCase		,	(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["merges_file"]							)

		with open(lowerCAmelCase		,	"w"		,	encoding="utf-8"							) as f:
			f.write(json.dumps(self.encoder		,	indent=2		,	sort_keys=lowerCAmelCase		,	ensure_ascii=lowerCAmelCase							) + "\n"							)

		UpperCAmelCase_       				=			0
		with open(lowerCAmelCase		,	"w"		,	encoding="utf-8"							) as writer:
			writer.write("#version: 0.2\n"							)
			for bpe_tokens, token_index in sorted(self.bpe_ranks.items()		,	key=lambda lowerCAmelCase							: kv[1]							):
				if index != token_index:
					logger.warning(
					    F"Saving vocabulary to {merge_file}: BPE merge indices are not consecutive."
					    " Please check that the tokenizer is not corrupted!"							)
					UpperCAmelCase_       				=			token_index
				writer.write(" ".join(lowerCAmelCase							) + "\n"							)
				index += 1

		return vocab_file, merge_file




	def       __A					(		self	:						Union[str, Any]		,	lowerCAmelCase	:						List[int]		,	lowerCAmelCase	:						Optional[List[int]] = None							):


		'''simple docstring'''







		if token_ids_a is None:
			return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
		UpperCAmelCase_       				=			[self.cls_token_id]
		UpperCAmelCase_       				=			[self.sep_token_id]
		return cls + token_ids_a + sep + sep + token_ids_a + sep




	def       __A					(		self	:						int		,	lowerCAmelCase	:						List[int]		,	lowerCAmelCase	:						Optional[List[int]] = None		,	lowerCAmelCase	:						bool = False							):


		'''simple docstring'''







		if already_has_special_tokens:
			return super().get_special_tokens_mask(
			    token_ids_a=lowerCAmelCase		,	token_ids_a=lowerCAmelCase		,	already_has_special_tokens=lowerCAmelCase							)

		if token_ids_a is None:
			return [1] + ([0] * len(lowerCAmelCase							)) + [1]
		return [1] + ([0] * len(lowerCAmelCase							)) + [1, 1] + ([0] * len(lowerCAmelCase							)) + [1]




	def       __A					(		self	:						Dict		,	lowerCAmelCase	:						List[int]		,	lowerCAmelCase	:						Optional[List[int]] = None							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[self.sep_token_id]
		UpperCAmelCase_       				=			[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]




	def       __A					(		self	:						Any		,	lowerCAmelCase	:						List[str]		,	lowerCAmelCase	:						Optional[int]=False		,	**lowerCAmelCase	:						Dict							):


		'''simple docstring'''







		UpperCAmelCase_       				=			kwargs.pop("add_prefix_space"		,	self.add_prefix_space							)
		if (is_split_into_words or add_prefix_space) and (len(lowerCAmelCase							) > 0 and not text[0].isspace()):
			UpperCAmelCase_       				=			" " + text
		return (text, kwargs)


import json
import os
from pathlib import Path
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple, Union

import sentencepiece

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


_a:    List[Any] 							=			logging.get_logger(__name__)

_a:    List[str] 							=			"""▁"""

_a:    Union[str, Any] 							=			{
    """vocab_file""": """vocab.json""",
    """spm_file""": """sentencepiece.bpe.model""",
}

_a:    Tuple 							=			{
    """vocab_file""": {
        """facebook/s2t-small-librispeech-asr""": (
            """https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/vocab.json"""
        ),
    },
    """spm_file""": {
        """facebook/s2t-small-librispeech-asr""": (
            """https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/sentencepiece.bpe.model"""
        )
    },
}

_a:    Optional[int] 							=			{
    """facebook/s2t-small-librispeech-asr""": 1024,
}

_a:    List[Any] 							=			["""pt""", """fr""", """ru""", """nl""", """ro""", """it""", """es""", """de"""]

_a:    Tuple 							=			{"""mustc""": MUSTC_LANGS}

class 						__UpperCamelCase    (					lowercase						):
	SCREAMING_SNAKE_CASE__    				=     VOCAB_FILES_NAMES
	SCREAMING_SNAKE_CASE__    				=     PRETRAINED_VOCAB_FILES_MAP
	SCREAMING_SNAKE_CASE__    				=     MAX_MODEL_INPUT_SIZES
	SCREAMING_SNAKE_CASE__    				=     ['input_ids', 'attention_mask']

	SCREAMING_SNAKE_CASE__    				=     []




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


		'''simple docstring'''







		UpperCAmelCase_       				=			{} if sp_model_kwargs is None else sp_model_kwargs

		super().__init__(
		    bos_token=lowerCAmelCase		,	eos_token=lowerCAmelCase		,	unk_token=lowerCAmelCase		,	pad_token=lowerCAmelCase		,	do_upper_case=lowerCAmelCase		,	do_lower_case=lowerCAmelCase		,	tgt_lang=lowerCAmelCase		,	lang_codes=lowerCAmelCase		,	sp_model_kwargs=self.sp_model_kwargs		,	**lowerCAmelCase		,	)
		UpperCAmelCase_       				=			do_upper_case
		UpperCAmelCase_       				=			do_lower_case

		UpperCAmelCase_       				=			load_json(lowerCAmelCase							)
		UpperCAmelCase_       				=			{v: k for k, v in self.encoder.items()}
		UpperCAmelCase_       				=			spm_file
		UpperCAmelCase_       				=			load_spm(lowerCAmelCase		,	self.sp_model_kwargs							)

		if lang_codes is not None:
			UpperCAmelCase_       				=			lang_codes
			UpperCAmelCase_       				=			LANGUAGES[lang_codes]
			UpperCAmelCase_       				=			[F"<lang:{lang}>" for lang in self.langs]
			UpperCAmelCase_       				=			{lang: self.sp_model.PieceToId(F"<lang:{lang}>"							) for lang in self.langs}

			UpperCAmelCase_       				=			self.lang_tokens
			UpperCAmelCase_       				=			tgt_lang if tgt_lang is not None else self.langs[0]

			self.set_tgt_lang_special_tokens(self._tgt_lang							)
		else:
			UpperCAmelCase_       				=			{}




	@property
	def       __A					(		self	:						List[Any]							):


		'''simple docstring'''







		return len(self.encoder							)




	@property
	def       __A					(		self	:						Any							):


		'''simple docstring'''







		return self._tgt_lang




	@tgt_lang.setter
	def       __A					(		self	:						int		,	lowerCAmelCase	:						Optional[Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			new_tgt_lang
		self.set_tgt_lang_special_tokens(lowerCAmelCase							)




	def       __A					(		self	:						List[Any]		,	lowerCAmelCase	:						str							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.lang_code_to_id[tgt_lang]
		UpperCAmelCase_       				=			[lang_code_id]




	def       __A					(		self	:						List[str]		,	lowerCAmelCase	:						str							):


		'''simple docstring'''







		return self.sp_model.encode(lowerCAmelCase		,	out_type=lowerCAmelCase							)




	def       __A					(		self	:						str		,	lowerCAmelCase	:						int							):


		'''simple docstring'''







		return self.encoder.get(lowerCAmelCase		,	self.encoder[self.unk_token]							)




	def       __A					(		self	:						Optional[Any]		,	lowerCAmelCase	:						int							):


		'''simple docstring'''







		return self.decoder.get(lowerCAmelCase		,	self.unk_token							)




	def       __A					(		self	:						Dict		,	lowerCAmelCase	:						List[str]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			[]
		UpperCAmelCase_       				=			""
		for token in tokens:
			# make sure that special tokens are not decoded using sentencepiece model
			if token in self.all_special_tokens:
				UpperCAmelCase_       				=			self.sp_model.decode(lowerCAmelCase							)
				out_string += (decoded.upper() if self.do_upper_case else decoded) + token + " "
				UpperCAmelCase_       				=			[]
			else:
				current_sub_tokens.append(lowerCAmelCase							)
		UpperCAmelCase_       				=			self.sp_model.decode(lowerCAmelCase							)
		out_string += decoded.upper() if self.do_upper_case else decoded
		return out_string.strip()




	def       __A					(		self	:						Optional[Any]		,	lowerCAmelCase	:						List[Any]		,	lowerCAmelCase	:						Optional[int]=None							):


		'''simple docstring'''







		if token_ids_a is None:
			return self.prefix_tokens + token_ids_a + [self.eos_token_id]
		# We don't expect to process pairs, but leave the pair logic for API consistency
		return self.prefix_tokens + token_ids_a + token_ids_a + [self.eos_token_id]




	def       __A					(		self	:						Any		,	lowerCAmelCase	:						List[int]		,	lowerCAmelCase	:						Optional[List[int]] = None		,	lowerCAmelCase	:						bool = False							):


		'''simple docstring'''







		if already_has_special_tokens:
			return super().get_special_tokens_mask(
			    token_ids_a=lowerCAmelCase		,	token_ids_a=lowerCAmelCase		,	already_has_special_tokens=lowerCAmelCase							)

		UpperCAmelCase_       				=			[1] * len(self.prefix_tokens							)
		UpperCAmelCase_       				=			[1]
		if token_ids_a is None:
			return prefix_ones + ([0] * len(lowerCAmelCase							)) + suffix_ones
		return prefix_ones + ([0] * len(lowerCAmelCase							)) + ([0] * len(lowerCAmelCase							)) + suffix_ones




	def       __A					(		self	:						Optional[Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.encoder.copy()
		vocab.update(self.added_tokens_encoder							)
		return vocab




	def __getstate__(		self	:						Union[str, Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.__dict__.copy()
		UpperCAmelCase_       				=			None
		return state




	def __setstate__(		self	:						Tuple		,	lowerCAmelCase	:						Dict							):


		'''simple docstring'''







		UpperCAmelCase_       				=			d

		# for backward compatibility
		if not hasattr(self		,	"sp_model_kwargs"							):
			UpperCAmelCase_       				=			{}

		UpperCAmelCase_       				=			load_spm(self.spm_file		,	self.sp_model_kwargs							)




	def       __A					(		self	:						Optional[Any]		,	lowerCAmelCase	:						str		,	lowerCAmelCase	:						Optional[str] = None							):


		'''simple docstring'''







		UpperCAmelCase_       				=			Path(lowerCAmelCase							)
		assert save_dir.is_dir(), F"{save_directory} should be a directory"
		UpperCAmelCase_       				=			save_dir / (
		    (filename_prefix + "-" if filename_prefix else "") + self.vocab_files_names["vocab_file"]
		)
		UpperCAmelCase_       				=			save_dir / (
		    (filename_prefix + "-" if filename_prefix else "") + self.vocab_files_names["spm_file"]
		)

		save_json(self.encoder		,	lowerCAmelCase							)

		if os.path.abspath(self.spm_file							) != os.path.abspath(lowerCAmelCase							) and os.path.isfile(self.spm_file							):
			copyfile(self.spm_file		,	lowerCAmelCase							)
		elif not os.path.isfile(self.spm_file							):
			with open(lowerCAmelCase		,	"wb"							) as fi:
				UpperCAmelCase_       				=			self.sp_model.serialized_model_proto()
				fi.write(lowerCAmelCase							)

		return (str(lowerCAmelCase							), str(lowerCAmelCase							))



def       __lowerCAmelCase      (						A       ,     A    ):
	UpperCAmelCase_       				=			sentencepiece.SentencePieceProcessor(**A    )
	spm.Load(str(A    )    )
	return spm



def       __lowerCAmelCase      (						A    ):
	with open(A       ,     "r"    ) as f:
		return json.load(A    )




def       __lowerCAmelCase      (						A       ,     A    ):
	with open(A       ,     "w"    ) as f:
		json.dump(A       ,     A       ,     indent=2    )