



'''simple docstring'''

import dataclasses
import re
import string
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple

import numpy as np

from . import residue_constants


UpperCAmelCase     		=   Mapping[str, np.ndarray]
UpperCAmelCase     		=   Mapping[str, Any]  # Is a nested dict.
UpperCAmelCase     		=   0.01

@dataclasses.dataclass(frozen=_lowerCAmelCase )
class __snake_case:


						'''simple docstring'''



						UpperCAmelCase							:   np.ndarray  # [num_res, num_atom_type, 3]

						# Amino-acid type for each residue represented as an integer between 0 and
						# 20, where 20 is 'X'.
						UpperCAmelCase							:   np.ndarray  # [num_res]

						# Binary float mask to indicate presence of a particular atom. 1.0 if an atom
						# is present and 0.0 if not. This should be used for loss masking.
						UpperCAmelCase							:   np.ndarray  # [num_res, num_atom_type]

						# Residue index as used in PDB. It is not necessarily continuous or 0-indexed.
						UpperCAmelCase							:   np.ndarray  # [num_res]

						# B-factors, or temperature factors, of each residue (in sq. angstroms units),
						# representing the displacement of the residue from its ground truth mean
						# value.
						UpperCAmelCase							:   np.ndarray  # [num_res, num_atom_type]

						# Chain indices for multi-chain predictions
						UpperCAmelCase							:   Optional[np.ndarray]									=		None

						# Optional remark about the protein. Included as a comment in output PDB
						# files
						UpperCAmelCase							:   Optional[str]									=		None

						# Templates used to generate this protein (prediction-only)
						UpperCAmelCase							:   Optional[Sequence[str]]									=		None

						# Chain corresponding to each parent
						UpperCAmelCase							:   Optional[Sequence[int]]									=		None







def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						Protein:







	"""simple docstring"""
	lowerCAmelCase   =     R"""(\[[A-Z]+\]\n)"""
	lowerCAmelCase   =     [tag.strip() for tag in re.split(_SCREAMING_SNAKE_CASE							,		_SCREAMING_SNAKE_CASE							) if len(_SCREAMING_SNAKE_CASE							) > 0]
	lowerCAmelCase   =     zip(tags[0::2]							,		[l.split("""\n"""							) for l in tags[1::2]]							)

	lowerCAmelCase   =     ["N", "CA", "C"]
	lowerCAmelCase   =     None
	lowerCAmelCase   =     None
	lowerCAmelCase   =     None
	for g in groups:
		if "[PRIMARY]" == g[0]:
			lowerCAmelCase   =     g[1][0].strip()
			for i in range(len(_SCREAMING_SNAKE_CASE							)							):
				if seq[i] not in residue_constants.restypes:
					lowerCAmelCase   =     """X"""  # FIXME: strings are immutable
			lowerCAmelCase   =     np.array(
			    [residue_constants.restype_order.get(_SCREAMING_SNAKE_CASE							,		residue_constants.restype_num							) for res_symbol in seq]							)
		elif "[TERTIARY]" == g[0]:
			lowerCAmelCase   =     []
			for axis in range(3							):
				tertiary.append(list(map(_SCREAMING_SNAKE_CASE							,		g[1][axis].split()							)							)							)
			lowerCAmelCase   =     np.array(_SCREAMING_SNAKE_CASE							)
			lowerCAmelCase   =     np.zeros((len(tertiary[0]							) // 3, residue_constants.atom_type_num, 3)							).astype(np.floataa							)
			for i, atom in enumerate(_SCREAMING_SNAKE_CASE							):
				lowerCAmelCase   =     np.transpose(tertiary_np[:, i::3]							)
			atom_positions *= PICO_TO_ANGSTROM
		elif "[MASK]" == g[0]:
			lowerCAmelCase   =     np.array(list(map({"""-""": 0, """+""": 1}.get							,		g[1][0].strip()							)							)							)
			lowerCAmelCase   =     np.zeros(
			    (
			        len(_SCREAMING_SNAKE_CASE							),
			        residue_constants.atom_type_num,
			    )							).astype(np.floataa							)
			for i, atom in enumerate(_SCREAMING_SNAKE_CASE							):
				lowerCAmelCase   =     1
			atom_mask *= mask[..., None]

	assert aatype is not None

	return Protein(
	    atom_positions=_SCREAMING_SNAKE_CASE							,		atom_mask=_SCREAMING_SNAKE_CASE							,		aatype=_SCREAMING_SNAKE_CASE							,		residue_index=np.arange(len(_SCREAMING_SNAKE_CASE							)							)							,		b_factors=_SCREAMING_SNAKE_CASE							,		)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						Protein							,		_SCREAMING_SNAKE_CASE					:						int = 0							)      ->						List[str]:







	"""simple docstring"""
	lowerCAmelCase   =     []

	lowerCAmelCase   =     prot.remark
	if remark is not None:
		pdb_headers.append(f'REMARK {remark}'							)

	lowerCAmelCase   =     prot.parents
	lowerCAmelCase   =     prot.parents_chain_index
	if parents is not None and parents_chain_index is not None:
		lowerCAmelCase   =     [p for i, p in zip(_SCREAMING_SNAKE_CASE							,		_SCREAMING_SNAKE_CASE							) if i == chain_id]

	if parents is None or len(_SCREAMING_SNAKE_CASE							) == 0:
		lowerCAmelCase   =     ["""N/A"""]

	pdb_headers.append(f'PARENT {" ".join(_SCREAMING_SNAKE_CASE							)}'							)

	return pdb_headers






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						Protein							,		_SCREAMING_SNAKE_CASE					:						str							)      ->						str:







	"""simple docstring"""
	lowerCAmelCase   =     []
	lowerCAmelCase   =     pdb_str.split("""\n"""							)

	lowerCAmelCase   =     prot.remark
	if remark is not None:
		out_pdb_lines.append(f'REMARK {remark}'							)

	lowerCAmelCase   =     42
	if prot.parents is not None and len(prot.parents							) > 0:
		lowerCAmelCase   =     []
		if prot.parents_chain_index is not None:
			lowerCAmelCase   =     {}
			for p, i in zip(prot.parents							,		prot.parents_chain_index							):
				parent_dict.setdefault(str(_SCREAMING_SNAKE_CASE							)							,		[]							)
				parent_dict[str(_SCREAMING_SNAKE_CASE							)].append(_SCREAMING_SNAKE_CASE							)

			lowerCAmelCase   =     max([int(_SCREAMING_SNAKE_CASE							) for chain_idx in parent_dict]							)
			for i in range(max_idx + 1							):
				lowerCAmelCase   =     parent_dict.get(str(_SCREAMING_SNAKE_CASE							)							,		["""N/A"""]							)
				parents_per_chain.append(_SCREAMING_SNAKE_CASE							)
		else:
			parents_per_chain.append(list(prot.parents							)							)
	else:
		lowerCAmelCase   =     [["""N/A"""]]

	def make_parent_line(_SCREAMING_SNAKE_CASE					:						Sequence[str]							) -> str:
		return f'PARENT {" ".join(_SCREAMING_SNAKE_CASE							)}'

	out_pdb_lines.append(make_parent_line(parents_per_chain[0]							)							)

	lowerCAmelCase   =     0
	for i, l in enumerate(_SCREAMING_SNAKE_CASE							):
		if "PARENT" not in l and "REMARK" not in l:
			out_pdb_lines.append(_SCREAMING_SNAKE_CASE							)
		if "TER" in l and "END" not in lines[i + 1]:
			chain_counter += 1
			if not chain_counter >= len(_SCREAMING_SNAKE_CASE							):
				lowerCAmelCase   =     parents_per_chain[chain_counter]
			else:
				lowerCAmelCase   =     ["""N/A"""]

			out_pdb_lines.append(make_parent_line(_SCREAMING_SNAKE_CASE							)							)

	return "\n".join(_SCREAMING_SNAKE_CASE							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						Protein							)      ->						str:







	"""simple docstring"""
	lowerCAmelCase   =     residue_constants.restypes + ["""X"""]

	def res_atoa(_SCREAMING_SNAKE_CASE					:						int							) -> str:
		return residue_constants.restype_atoa.get(restypes[r]							,		"""UNK"""							)

	lowerCAmelCase   =     residue_constants.atom_types

	lowerCAmelCase   =     []

	lowerCAmelCase   =     prot.atom_mask
	lowerCAmelCase   =     prot.aatype
	lowerCAmelCase   =     prot.atom_positions
	lowerCAmelCase   =     prot.residue_index.astype(np.intaa							)
	lowerCAmelCase   =     prot.b_factors
	lowerCAmelCase   =     prot.chain_index

	if np.any(aatype > residue_constants.restype_num							):
		raise ValueError("""Invalid aatypes."""							)

	lowerCAmelCase   =     get_pdb_headers(_SCREAMING_SNAKE_CASE							)
	if len(_SCREAMING_SNAKE_CASE							) > 0:
		pdb_lines.extend(_SCREAMING_SNAKE_CASE							)

	lowerCAmelCase   =     aatype.shape[0]
	lowerCAmelCase   =     1
	lowerCAmelCase   =     0
	lowerCAmelCase   =     string.ascii_uppercase
	lowerCAmelCase   =     None
	# Add all atom sites.
	for i in range(_SCREAMING_SNAKE_CASE							):
		lowerCAmelCase   =     res_atoa(aatype[i]							)
		for atom_name, pos, mask, b_factor in zip(_SCREAMING_SNAKE_CASE							,		atom_positions[i]							,		atom_mask[i]							,		b_factors[i]							):
			if mask < 0.5:
				continue

			lowerCAmelCase   =     """ATOM"""
			lowerCAmelCase   =     atom_name if len(_SCREAMING_SNAKE_CASE							) == 4 else f' {atom_name}'
			lowerCAmelCase   =     """"""
			lowerCAmelCase   =     """"""
			lowerCAmelCase   =     1.00
			lowerCAmelCase   =     atom_name[0]  # Protein supports only C, N, O, S, this works.
			lowerCAmelCase   =     """"""

			lowerCAmelCase   =     """A"""
			if chain_index is not None:
				lowerCAmelCase   =     chain_tags[chain_index[i]]

			# PDB is a columnar format, every space matters here!
			lowerCAmelCase   =     (
			    f'{record_type:<6}{atom_index:>5} {name:<4}{alt_loc:>1}'
			    f'{res_name_a:>3} {chain_tag:>1}'
			    f'{residue_index[i]:>4}{insertion_code:>1}   '
			    f'{pos[0]:>8.3f}{pos[1]:>8.3f}{pos[2]:>8.3f}'
			    f'{occupancy:>6.2f}{b_factor:>6.2f}          '
			    f'{element:>2}{charge:>2}'
			)
			pdb_lines.append(_SCREAMING_SNAKE_CASE							)
			atom_index += 1

		lowerCAmelCase   =     i == n - 1
		if chain_index is not None:
			if i != n - 1 and chain_index[i + 1] != prev_chain_index:
				lowerCAmelCase   =     True
				lowerCAmelCase   =     chain_index[i + 1]

		if should_terminate:
			# Close the chain.
			lowerCAmelCase   =     """TER"""
			lowerCAmelCase   =     (
			    f'{chain_end:<6}{atom_index:>5}      {res_atoa(aatype[i]							):>3} {chain_tag:>1}{residue_index[i]:>4}'
			)
			pdb_lines.append(_SCREAMING_SNAKE_CASE							)
			atom_index += 1

			if i != n - 1:
				# "prev" is a misnomer here. This happens at the beginning of
				# each new chain.
				pdb_lines.extend(get_pdb_headers(_SCREAMING_SNAKE_CASE							,		_SCREAMING_SNAKE_CASE							)							)

	pdb_lines.append("""END"""							)
	pdb_lines.append(""""""							)
	return "\n".join(_SCREAMING_SNAKE_CASE							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						Protein							)      ->						np.ndarray:







	"""simple docstring"""
	return residue_constants.STANDARD_ATOM_MASK[prot.aatype]






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						FeatureDict							,		_SCREAMING_SNAKE_CASE					:						ModelOutput							,		_SCREAMING_SNAKE_CASE					:						Optional[np.ndarray] = None							,		_SCREAMING_SNAKE_CASE					:						Optional[np.ndarray] = None							,		_SCREAMING_SNAKE_CASE					:						Optional[str] = None							,		_SCREAMING_SNAKE_CASE					:						Optional[Sequence[str]] = None							,		_SCREAMING_SNAKE_CASE					:						Optional[Sequence[int]] = None							,		)      ->						Protein:







	"""simple docstring"""
	return Protein(
	    aatype=features["""aatype"""]							,		atom_positions=result["""final_atom_positions"""]							,		atom_mask=result["""final_atom_mask"""]							,		residue_index=features["""residue_index"""] + 1							,		b_factors=b_factors if b_factors is not None else np.zeros_like(result["""final_atom_mask"""]							)							,		chain_index=_SCREAMING_SNAKE_CASE							,		remark=_SCREAMING_SNAKE_CASE							,		parents=_SCREAMING_SNAKE_CASE							,		parents_chain_index=_SCREAMING_SNAKE_CASE							,		)




'''simple docstring'''

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 BatchEncoding, PreTrainedTokenizer
from ...utils import logging


UpperCAmelCase     		=   logging.get_logger(__name__)

UpperCAmelCase     		=   '▁'

UpperCAmelCase     		=   {
    'vocab_file': 'vocab.json',
    'spm_file': 'sentencepiece.bpe.model',
    'tokenizer_config_file': 'tokenizer_config.json',
}

UpperCAmelCase     		=   {
    'vocab_file': {
        'facebook/m2m100_418M': 'https://huggingface.co/facebook/m2m100_418M/resolve/main/vocab.json',
        'facebook/m2m100_1.2B': 'https://huggingface.co/facebook/m2m100_1.2B/resolve/main/vocab.json',
    },
    'spm_file': {
        'facebook/m2m100_418M': 'https://huggingface.co/facebook/m2m100_418M/resolve/main/sentencepiece.bpe.model',
        'facebook/m2m100_1.2B': 'https://huggingface.co/facebook/m2m100_1.2B/resolve/main/sentencepiece.bpe.model',
    },
    'tokenizer_config_file': {
        'facebook/m2m100_418M': 'https://huggingface.co/facebook/m2m100_418M/resolve/main/tokenizer_config.json',
        'facebook/m2m100_1.2B': 'https://huggingface.co/facebook/m2m100_1.2B/resolve/main/tokenizer_config.json',
    },
}

UpperCAmelCase     		=   {
    'facebook/m2m100_418M': 1024,
}

# fmt: off
UpperCAmelCase     		=   {
    'm2m100': ['af', 'am', 'ar', 'ast', 'az', 'ba', 'be', 'bg', 'bn', 'br', 'bs', 'ca', 'ceb', 'cs', 'cy', 'da', 'de', 'el', 'en', 'es', 'et', 'fa', 'ff', 'fi', 'fr', 'fy', 'ga', 'gd', 'gl', 'gu', 'ha', 'he', 'hi', 'hr', 'ht', 'hu', 'hy', 'id', 'ig', 'ilo', 'is', 'it', 'ja', 'jv', 'ka', 'kk', 'km', 'kn', 'ko', 'lb', 'lg', 'ln', 'lo', 'lt', 'lv', 'mg', 'mk', 'ml', 'mn', 'mr', 'ms', 'my', 'ne', 'nl', 'no', 'ns', 'oc', 'or', 'pa', 'pl', 'ps', 'pt', 'ro', 'ru', 'sd', 'si', 'sk', 'sl', 'so', 'sq', 'sr', 'ss', 'su', 'sv', 'sw', 'ta', 'th', 'tl', 'tn', 'tr', 'uk', 'ur', 'uz', 'vi', 'wo', 'xh', 'yi', 'yo', 'zh', 'zu'],
    'wmt21': ['en', 'ha', 'is', 'ja', 'cs', 'ru', 'zh', 'de']
}

class __snake_case(				_lowerCAmelCase ):


						'''simple docstring'''



						UpperCAmelCase							:   Optional[int]									=		VOCAB_FILES_NAMES
						UpperCAmelCase							:   Optional[Any]									=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						UpperCAmelCase							:   Optional[int]									=		PRETRAINED_VOCAB_FILES_MAP
						UpperCAmelCase							:   int									=		["input_ids", "attention_mask"]

						UpperCAmelCase							:   List[int]									=		[]
						UpperCAmelCase							:   List[int]									=		[]


						def __init__( self     ,	A_     ,	A_     ,	A_=None     ,	A_=None     ,	A_="<s>"     ,	A_="</s>"     ,	A_="</s>"     ,	A_="<pad>"     ,	A_="<unk>"     ,	A_="m2m100"     ,	A_ = None     ,	A_=8     ,	**A_     ,	)     ->     None:
							lowerCAmelCase   =     {} if sp_model_kwargs is None else sp_model_kwargs

							lowerCAmelCase   =     language_codes
							lowerCAmelCase   =     FAIRSEQ_LANGUAGE_CODES[language_codes]
							lowerCAmelCase   =     {lang_code: f'__{lang_code}__' for lang_code in fairseq_language_code}

							lowerCAmelCase   =     kwargs.get("""additional_special_tokens"""     ,	[]				)
							kwargs["additional_special_tokens"] += [
							    self.get_lang_token(A_				)
							    for lang_code in fairseq_language_code
							    if self.get_lang_token(A_				) not in kwargs["additional_special_tokens"]
							]

							super().__init__(
							    src_lang=A_     ,	tgt_lang=A_     ,	bos_token=A_     ,	eos_token=A_     ,	sep_token=A_     ,	unk_token=A_     ,	pad_token=A_     ,	language_codes=A_     ,	sp_model_kwargs=self.sp_model_kwargs     ,	num_madeup_words=A_     ,	**A_     ,	)

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

							lowerCAmelCase   =     len(self.encoder				)

							lowerCAmelCase   =     {
							    self.get_lang_token(A_				): self.encoder_size + i for i, lang_code in enumerate(A_				)
							}
							lowerCAmelCase   =     {lang_code: self.encoder_size + i for i, lang_code in enumerate(A_				)}
							lowerCAmelCase   =     {v: k for k, v in self.lang_token_to_id.items()}

							lowerCAmelCase   =     src_lang if src_lang is not None else """en"""
							lowerCAmelCase   =     tgt_lang
							lowerCAmelCase   =     self.get_lang_id(self._src_lang				)
							self.set_src_lang_special_tokens(self._src_lang				)

							lowerCAmelCase   =     num_madeup_words


						@property
						def     __snake_case   ( self				)     ->     int:
							return len(self.encoder				) + len(self.lang_token_to_id				)


						@property
						def     __snake_case   ( self				)     ->     str:
							return self._src_lang


						@src_lang.setter
						def     __snake_case   ( self     ,	A_				)     ->     None:
							lowerCAmelCase   =     new_src_lang
							self.set_src_lang_special_tokens(self._src_lang				)


						def     __snake_case   ( self     ,	A_				)     ->     List[str]:
							return self.sp_model.encode(A_     ,	out_type=A_				)


						def     __snake_case   ( self     ,	A_				)     ->     Any:
							if token in self.lang_token_to_id:
								return self.lang_token_to_id[token]
							return self.encoder.get(A_     ,	self.encoder[self.unk_token]				)


						def     __snake_case   ( self     ,	A_				)     ->     str:
							if index in self.id_to_lang_token:
								return self.id_to_lang_token[index]
							return self.decoder.get(A_     ,	self.unk_token				)


						def     __snake_case   ( self     ,	A_				)     ->     List[str]:
							lowerCAmelCase   =     []
							lowerCAmelCase   =     """"""
							for token in tokens:
								# make sure that special tokens are not decoded using sentencepiece model
								if token in self.all_special_tokens:
									out_string += self.sp_model.decode(A_				) + token
									lowerCAmelCase   =     []
								else:
									current_sub_tokens.append(A_				)
							out_string += self.sp_model.decode(A_				)
							return out_string.strip()


						def     __snake_case   ( self     ,	A_     ,	A_ = None     ,	A_ = False				)     ->     List[int]:

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

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


						def     __snake_case   ( self     ,	A_     ,	A_ = None				)     ->     List[int]:
							if token_ids_a is None:
								return self.prefix_tokens + token_ids_a + self.suffix_tokens
							# 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.suffix_tokens


						def     __snake_case   ( self				)     ->     Dict:
							lowerCAmelCase   =     {self.convert_ids_to_tokens(A_				): i for i in range(self.vocab_size				)}
							vocab.update(self.added_tokens_encoder				)
							return vocab


						def __getstate__( self				)     ->     Dict:
							lowerCAmelCase   =     self.__dict__.copy()
							lowerCAmelCase   =     None
							return state


						def __setstate__( self     ,	A_				)     ->     None:
							lowerCAmelCase   =     d

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

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


						def     __snake_case   ( self     ,	A_     ,	A_ = None				)     ->     Tuple[str]:
							lowerCAmelCase   =     Path(A_				)
							if not save_dir.is_dir():
								raise OSError(f'{save_directory} should be a directory'				)
							lowerCAmelCase   =     save_dir / (
							    (filename_prefix + """-""" if filename_prefix else """""") + self.vocab_files_names["""vocab_file"""]
							)
							lowerCAmelCase   =     save_dir / (
							    (filename_prefix + """-""" if filename_prefix else """""") + self.vocab_files_names["""spm_file"""]
							)

							save_json(self.encoder     ,	A_				)

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

							return (str(A_				), str(A_				))


						def     __snake_case   ( self     ,	A_     ,	A_ = "en"     ,	A_ = None     ,	A_ = "ro"     ,	**A_     ,	)     ->     BatchEncoding:
							lowerCAmelCase   =     src_lang
							lowerCAmelCase   =     tgt_lang
							self.set_src_lang_special_tokens(self.src_lang				)
							return super().prepare_seqaseq_batch(A_     ,	A_     ,	**A_				)


						def     __snake_case   ( self     ,	A_     ,	A_     ,	A_     ,	**A_				)     ->     str:
							if src_lang is None or tgt_lang is None:
								raise ValueError("""Translation requires a `src_lang` and a `tgt_lang` for this model"""				)
							lowerCAmelCase   =     src_lang
							lowerCAmelCase   =     self(A_     ,	add_special_tokens=A_     ,	**A_				)
							lowerCAmelCase   =     self.get_lang_id(A_				)
							lowerCAmelCase   =     tgt_lang_id
							return inputs


						def     __snake_case   ( self				)     ->     Any:
							self.set_src_lang_special_tokens(self.src_lang				)


						def     __snake_case   ( self				)     ->     Optional[int]:
							self.set_tgt_lang_special_tokens(self.tgt_lang				)


						def     __snake_case   ( self     ,	A_				)     ->     None:
							lowerCAmelCase   =     self.get_lang_token(A_				)
							lowerCAmelCase   =     self.lang_token_to_id[lang_token]
							lowerCAmelCase   =     [self.cur_lang_id]
							lowerCAmelCase   =     [self.eos_token_id]


						def     __snake_case   ( self     ,	A_				)     ->     None:
							lowerCAmelCase   =     self.get_lang_token(A_				)
							lowerCAmelCase   =     self.lang_token_to_id[lang_token]
							lowerCAmelCase   =     [self.cur_lang_id]
							lowerCAmelCase   =     [self.eos_token_id]


						def     __snake_case   ( self     ,	A_				)     ->     str:
							return self.lang_code_to_token[lang]




						def     __snake_case   ( self     ,	A_				)     ->     int:
							lowerCAmelCase   =     self.get_lang_token(A_				)
							return self.lang_token_to_id[lang_token]







def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							,		_SCREAMING_SNAKE_CASE					:						Dict[str, Any]							)      ->						sentencepiece.SentencePieceProcessor:







	"""simple docstring"""
	lowerCAmelCase   =     sentencepiece.SentencePieceProcessor(**_SCREAMING_SNAKE_CASE							)
	spm.Load(str(_SCREAMING_SNAKE_CASE							)							)
	return spm






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						Union[Dict, List]:







	"""simple docstring"""
	with open(_SCREAMING_SNAKE_CASE							,		"""r"""							) as f:
		return json.load(_SCREAMING_SNAKE_CASE							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						Dict							,		_SCREAMING_SNAKE_CASE					:						str							)      ->						None:







	"""simple docstring"""
	with open(_SCREAMING_SNAKE_CASE							,		"""w"""							) as f:
		json.dump(_SCREAMING_SNAKE_CASE							,		_SCREAMING_SNAKE_CASE							,		indent=2							)