

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


lowercase__			    =			logging.get_logger(__name__)

lowercase__			    =			"▁"

lowercase__			    =			{
    "vocab_file": "vocab.json",
    "spm_file": "sentencepiece.bpe.model",
}

lowercase__			    =			{
    "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"
        )
    },
}

lowercase__			    =			{
    "facebook/s2t-small-librispeech-asr": 1024,
}

lowercase__			    =			["pt", "fr", "ru", "nl", "ro", "it", "es", "de"]

lowercase__			    =			{"mustc": MUSTC_LANGS}




class        A_ (				_snake_case							):






     '''simple docstring'''



     UpperCAmelCase_						:	Union[str, Any]  		=  VOCAB_FILES_NAMES
     UpperCAmelCase_						:	Any  		=  PRETRAINED_VOCAB_FILES_MAP
     UpperCAmelCase_						:	List[str]  		=  MAX_MODEL_INPUT_SIZES
     UpperCAmelCase_						:	Any  		=  ["""input_ids""", """attention_mask"""]

     UpperCAmelCase_						:	List[Any]  		=  []


     def __init__(		self :     Dict     ,			lowercase_ :     Optional[Any]     ,			lowercase_ :     Optional[Any]     ,			lowercase_ :     List[Any]="<s>"     ,			lowercase_ :     List[str]="</s>"     ,			lowercase_ :     Optional[int]="<pad>"     ,			lowercase_ :     List[str]="<unk>"     ,			lowercase_ :     Dict=False     ,			lowercase_ :     Optional[Any]=False     ,			lowercase_ :     Dict=None     ,			lowercase_ :     Dict=None     ,			lowercase_ :     Optional[Dict[str, Any]] = None     ,			**lowercase_ :     Tuple     ,			)						->	Dict:
      UpperCAmelCase       :	str											= {} 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       :	List[str]											= do_upper_case
      UpperCAmelCase       :	List[str]											= do_lower_case

      UpperCAmelCase       :	str											= load_json(_lowerCAmelCase       )
      UpperCAmelCase       :	List[Any]											= {v: k for k, v in self.encoder.items()}
      UpperCAmelCase       :	str											= spm_file
      UpperCAmelCase       :	Any											= load_spm(_lowerCAmelCase     ,			self.sp_model_kwargs       )

      if lang_codes is not None:
       UpperCAmelCase       :	List[str]											= lang_codes
       UpperCAmelCase       :	Tuple											= LANGUAGES[lang_codes]
       UpperCAmelCase       :	Any											= [f"""<lang:{lang}>""" for lang in self.langs]
       UpperCAmelCase       :	Any											= {lang: self.sp_model.PieceToId(f"""<lang:{lang}>"""       ) for lang in self.langs}

       UpperCAmelCase       :	Optional[Any]											= self.lang_tokens
       UpperCAmelCase       :	List[str]											= tgt_lang if tgt_lang is not None else self.langs[0]

       self.set_tgt_lang_special_tokens(self._tgt_lang       )
      else:
       UpperCAmelCase       :	Tuple											= {}


     @property
     def    UpperCAmelCase_       (		self :     Tuple       )						->	Union[str, Any]:
      return len(self.encoder       )


     @property
     def    UpperCAmelCase_       (		self :     Optional[Any]       )						->	Tuple:
      return self._tgt_lang


     @tgt_lang.setter
     def    UpperCAmelCase_       (		self :     List[Any]     ,			lowercase_ :     Optional[Any]       )						->	Optional[Any]:
      UpperCAmelCase       :	Any											= new_tgt_lang
      self.set_tgt_lang_special_tokens(_lowerCAmelCase       )


     def    UpperCAmelCase_       (		self :     Optional[int]     ,			lowercase_ :     str       )						->	Dict:
      UpperCAmelCase       :	Any											= self.lang_code_to_id[tgt_lang]
      UpperCAmelCase       :	List[Any]											= [lang_code_id]


     def    UpperCAmelCase_       (		self :     Optional[Any]     ,			lowercase_ :     str       )						->	Optional[Any]:
      return self.sp_model.encode(_lowerCAmelCase     ,			out_type=_lowerCAmelCase       )


     def    UpperCAmelCase_       (		self :     Dict     ,			lowercase_ :     Tuple       )						->	Dict:
      return self.encoder.get(_lowerCAmelCase     ,			self.encoder[self.unk_token]       )


     def    UpperCAmelCase_       (		self :     List[str]     ,			lowercase_ :     int       )						->	Dict:
      return self.decoder.get(_lowerCAmelCase     ,			self.unk_token       )


     def    UpperCAmelCase_       (		self :     List[Any]     ,			lowercase_ :     List[str]       )						->	int:
      UpperCAmelCase       :	int											= []
      UpperCAmelCase       :	Any											= ""
      for token in tokens:
       # make sure that special tokens are not decoded using sentencepiece model
       if token in self.all_special_tokens:
        UpperCAmelCase       :	Dict											= self.sp_model.decode(_lowerCAmelCase       )
        out_string += (decoded.upper() if self.do_upper_case else decoded) + token + " "
        UpperCAmelCase       :	Any											= []
       else:
        current_sub_tokens.append(_lowerCAmelCase       )
      UpperCAmelCase       :	Dict											= self.sp_model.decode(_lowerCAmelCase       )
      out_string += decoded.upper() if self.do_upper_case else decoded
      return out_string.strip()


     def    UpperCAmelCase_       (		self :     Any     ,			lowercase_ :     int     ,			lowercase_ :     str=None       )						->	List[str]:
      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    UpperCAmelCase_       (		self :     int     ,			lowercase_ :     List[int]     ,			lowercase_ :     Optional[List[int]] = None     ,			lowercase_ :     bool = False       )						->	List[Any]:

      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       :	int											= [1] * len(self.prefix_tokens       )
      UpperCAmelCase       :	List[str]											= [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    UpperCAmelCase_       (		self :     Dict       )						->	Union[str, Any]:
      UpperCAmelCase       :	int											= self.encoder.copy()
      vocab.update(self.added_tokens_encoder       )
      return vocab


     def __getstate__(		self :     Optional[Any]       )						->	int:
      UpperCAmelCase       :	Union[str, Any]											= self.__dict__.copy()
      UpperCAmelCase       :	Dict											= None
      return state


     def __setstate__(		self :     Union[str, Any]     ,			lowercase_ :     Dict       )						->	str:
      UpperCAmelCase       :	List[Any]											= d

      # for backward compatibility
      if not hasattr(self     ,			'sp_model_kwargs'       ):
       UpperCAmelCase       :	List[Any]											= {}

      UpperCAmelCase       :	Union[str, Any]											= load_spm(self.spm_file     ,			self.sp_model_kwargs       )




     def    UpperCAmelCase_       (		self :     Union[str, Any]     ,			lowercase_ :     str     ,			lowercase_ :     Optional[str] = None       )						->	Optional[Any]:
      UpperCAmelCase       :	List[str]											= Path(_lowerCAmelCase       )
      assert save_dir.is_dir(), f"""{save_directory} should be a directory"""
      UpperCAmelCase       :	List[Any]											= save_dir / (
          (filename_prefix + "-" if filename_prefix else "") + self.vocab_files_names["vocab_file"]
      )
      UpperCAmelCase       :	Any											= 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       :	int											= self.sp_model.serialized_model_proto()
        fi.write(_lowerCAmelCase       )

      return (str(_lowerCAmelCase       ), str(_lowerCAmelCase       ))




def       UpperCamelCase(     UpperCAmelCase_  ,       UpperCAmelCase_	):
 UpperCAmelCase       :	Tuple											= sentencepiece.SentencePieceProcessor(**UpperCAmelCase_	)
 spm.Load(str(UpperCAmelCase_	)	)
 return spm




def       UpperCamelCase(     UpperCAmelCase_	):
 with open(UpperCAmelCase_  ,       'r'	) as f:
  return json.load(UpperCAmelCase_	)




def       UpperCamelCase(     UpperCAmelCase_  ,       UpperCAmelCase_	):
 with open(UpperCAmelCase_  ,       'w'	) as f:
  json.dump(UpperCAmelCase_  ,       UpperCAmelCase_  ,       indent=2	)










_UpperCAmelCase		:  Tuple	=   {str(digit): digit**5 for digit in range(10)}



def 					UpperCAmelCase__     (   lowerCamelCase      ):
  return sum(DIGITS_FIFTH_POWER[digit] for digit in str(lowerCamelCase      )      )



def 					UpperCAmelCase__     (   ):
  return sum(
      number
      for number in range(1000,	1000000      )
      if number == digits_fifth_powers_sum(lowerCamelCase      )      )


if __name__ == "__main__":
     print(solution())



