


'''simple docstring'''







import json
import os
from typing import Optional, Tuple

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


lowerCAmelCase    :     Any					=						logging.get_logger(__name__)

lowerCAmelCase    :     Any					=						{"""vocab_file""": """vocab.json"""}

lowerCAmelCase    :     Optional[int]					=						{
    """vocab_file""": {
        """mgp-str""": """https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json""",
    }
}

lowerCAmelCase    :     Dict					=						{"""mgp-str""": 27}
class 	UpperCamelCase__					( SCREAMING_SNAKE_CASE_	):



     """simple docstring"""






     __magic_name__    			=    VOCAB_FILES_NAMES
     __magic_name__    			=    PRETRAINED_VOCAB_FILES_MAP
     __magic_name__    			=    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




     def __init__( self      ,	snake_case__      ,	snake_case__="[GO]"      ,	snake_case__="[GO]"      ,	snake_case__="[s]"      ,	snake_case__="[GO]"      ,	**snake_case__   ):

            '''simple docstring'''

            super().__init__(
                unk_token=snake_case__      ,	bos_token=snake_case__      ,	eos_token=snake_case__      ,	pad_token=snake_case__      ,	**snake_case__      ,	)

            with open(snake_case__      ,	encoding='utf-8'   ) as vocab_handle:
                   _lowerCAmelCase    :							Union[str, Any]   			=       json.load(snake_case__   )
            _lowerCAmelCase    :							int   			=       {v: k for k, v in self.vocab.items()}




     @property
     def a	( self   ):

            '''simple docstring'''

            return len(self.vocab   )




     def a	( self   ):

            '''simple docstring'''

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




     def a	( self      ,	snake_case__   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Tuple   			=       []
            for s in text:
                   char_tokens.extend(snake_case__   )
            return char_tokens




     def a	( self      ,	snake_case__   ):

            '''simple docstring'''

            return self.vocab.get(snake_case__      ,	self.vocab.get(self.unk_token   )   )




     def a	( self      ,	snake_case__   ):

            '''simple docstring'''

            return self.decoder.get(snake_case__   )





     def a	( self      ,	snake_case__      ,	snake_case__ = None   ):

            '''simple docstring'''

            if not os.path.isdir(snake_case__   ):
                   logger.error('Vocabulary path ({}) should be a directory'.format(snake_case__   )   )
                   return
            _lowerCAmelCase    :							List[Any]   			=       os.path.join(
                snake_case__      ,	(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']   )

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

            return (vocab_file,)





'''simple docstring'''







from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCAmelCase    :     Optional[int]					=						{
    """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""],
    """feature_extraction_mctct""": ["""MCTCTFeatureExtractor"""],
    """processing_mctct""": ["""MCTCTProcessor"""],
}


try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCAmelCase    :     List[str]					=						[
           """MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """MCTCTForCTC""",
           """MCTCTModel""",
           """MCTCTPreTrainedModel""",
       ]


if TYPE_CHECKING:
       from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
       from .feature_extraction_mctct import MCTCTFeatureExtractor
       from .processing_mctct import MCTCTProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
       import sys

       lowerCAmelCase    :     Tuple					=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

