




from __future__ import annotations

import unittest

from transformers import EsmConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
     import numpy
     import tensorflow as tf

     from transformers.models.esm.modeling_tf_esm import (
         TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
         TFEsmForMaskedLM,
         TFEsmForSequenceClassification,
         TFEsmForTokenClassification,
         TFEsmModel,
     )

class     __a:






    """simple docstring"""





    def __init__( self  ,_SCREAMING_SNAKE_CASE  ,)					->						Optional[int]:
         UpperCAmelCase_     :				Union[str, Any]  =     parent
         UpperCAmelCase_     :				Optional[Any]  =     13
         UpperCAmelCase_     :				List[Any]  =     7
         UpperCAmelCase_     :				Optional[Any]  =     True
         UpperCAmelCase_     :				Optional[Any]  =     True
         UpperCAmelCase_     :				Any  =     True
         UpperCAmelCase_     :				Tuple  =     99
         UpperCAmelCase_     :				str  =     32
         UpperCAmelCase_     :				str  =     2
         UpperCAmelCase_     :				List[str]  =     4
         UpperCAmelCase_     :				Any  =     37
         UpperCAmelCase_     :				Tuple  =     '''gelu'''
         UpperCAmelCase_     :				Union[str, Any]  =     0.1
         UpperCAmelCase_     :				List[Any]  =     0.1
         UpperCAmelCase_     :				str  =     512
         UpperCAmelCase_     :				List[str]  =     16
         UpperCAmelCase_     :				str  =     2
         UpperCAmelCase_     :				int  =     0.02
         UpperCAmelCase_     :				Dict  =     3
         UpperCAmelCase_     :				Union[str, Any]  =     4
         UpperCAmelCase_     :				str  =     None





    def 				a__ ( self    )					->						str:
         UpperCAmelCase_     :				List[str]  =     ids_tensor([self.batch_size, self.seq_length]  ,self.vocab_size    )

         UpperCAmelCase_     :				List[str]  =     None
         if self.use_input_mask:
              UpperCAmelCase_     :				List[str]  =     random_attention_mask([self.batch_size, self.seq_length]    )

         UpperCAmelCase_     :				Union[str, Any]  =     None
         UpperCAmelCase_     :				str  =     None
         UpperCAmelCase_     :				int  =     None
         if self.use_labels:
              UpperCAmelCase_     :				Dict  =     ids_tensor([self.batch_size]  ,self.type_sequence_label_size    )
              UpperCAmelCase_     :				Tuple  =     ids_tensor([self.batch_size, self.seq_length]  ,self.num_labels    )
              UpperCAmelCase_     :				Union[str, Any]  =     ids_tensor([self.batch_size]  ,self.num_choices    )

         UpperCAmelCase_     :				Union[str, Any]  =     EsmConfig(
             vocab_size=self.vocab_size  ,hidden_size=self.hidden_size  ,num_hidden_layers=self.num_hidden_layers  ,pad_token_id=1  ,num_attention_heads=self.num_attention_heads  ,intermediate_size=self.intermediate_size  ,hidden_act=self.hidden_act  ,hidden_dropout_prob=self.hidden_dropout_prob  ,attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,max_position_embeddings=self.max_position_embeddings  ,type_vocab_size=self.type_vocab_size  ,initializer_range=self.initializer_range  ,)

         return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels





    def 				a__ ( self    )					->						Optional[int]:
         (
             (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),             
         )     :				int  =     self.prepare_config_and_inputs()

         UpperCAmelCase_     :				Dict  =     True
         UpperCAmelCase_     :				int  =     floats_tensor([self.batch_size, self.seq_length, self.hidden_size]    )
         UpperCAmelCase_     :				List[str]  =     ids_tensor([self.batch_size, self.seq_length]  ,vocab_size=2    )

         return (
             config,
             input_ids,
             input_mask,
             sequence_labels,
             token_labels,
             choice_labels,
             encoder_hidden_states,
             encoder_attention_mask,
         )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE    )					->						str:
         UpperCAmelCase_     :				Any  =     TFEsmModel(config=_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				List[Any]  =     {'''input_ids''': input_ids, '''attention_mask''': input_mask}
         UpperCAmelCase_     :				str  =     model(_SCREAMING_SNAKE_CASE    )

         UpperCAmelCase_     :				Optional[Any]  =     [input_ids, input_mask]
         UpperCAmelCase_     :				Any  =     model(_SCREAMING_SNAKE_CASE    )

         UpperCAmelCase_     :				Any  =     model(_SCREAMING_SNAKE_CASE    )

         self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, self.seq_length, self.hidden_size)    )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,)					->						Optional[Any]:
         UpperCAmelCase_     :				List[Any]  =     True

         UpperCAmelCase_     :				List[Any]  =     TFEsmModel(config=_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Optional[int]  =     {
             '''input_ids''': input_ids,
             '''attention_mask''': input_mask,
             '''encoder_hidden_states''': encoder_hidden_states,
             '''encoder_attention_mask''': encoder_attention_mask,
         }
         UpperCAmelCase_     :				str  =     model(_SCREAMING_SNAKE_CASE    )

         UpperCAmelCase_     :				Dict  =     [input_ids, input_mask]
         UpperCAmelCase_     :				Union[str, Any]  =     model(_SCREAMING_SNAKE_CASE  ,encoder_hidden_states=_SCREAMING_SNAKE_CASE    )

         # Also check the case where encoder outputs are not passed
         UpperCAmelCase_     :				Any  =     model(_SCREAMING_SNAKE_CASE  ,attention_mask=_SCREAMING_SNAKE_CASE    )

         self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, self.seq_length, self.hidden_size)    )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE    )					->						Union[str, Any]:
         UpperCAmelCase_     :				Union[str, Any]  =     TFEsmForMaskedLM(config=_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Dict  =     model([input_ids, input_mask]    )
         self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.vocab_size)    )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE    )					->						Optional[int]:
         UpperCAmelCase_     :				int  =     self.num_labels
         UpperCAmelCase_     :				str  =     TFEsmForTokenClassification(config=_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				List[str]  =     {'''input_ids''': input_ids, '''attention_mask''': input_mask}
         UpperCAmelCase_     :				Union[str, Any]  =     model(_SCREAMING_SNAKE_CASE    )
         self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.seq_length, self.num_labels)    )





    def 				a__ ( self    )					->						Optional[int]:
         UpperCAmelCase_     :				str  =     self.prepare_config_and_inputs()
         (
             (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),       (
             UpperCAmelCase_      
         ),             
         )     :				Optional[int]  =     config_and_inputs
         UpperCAmelCase_     :				Dict  =     {'''input_ids''': input_ids, '''attention_mask''': input_mask}
         return config, inputs_dict


@require_tf
class     __a(	_lowerCAmelCase							,		_lowerCAmelCase							,		unittest.TestCase  ):






    """simple docstring"""





    lowerCAmelCase         = (
        (
            TFEsmModel,
            TFEsmForMaskedLM,
            TFEsmForSequenceClassification,
            TFEsmForTokenClassification,
        )
        if is_tf_available()
        else ()
    )
    lowerCAmelCase         = (
        {
            '''feature-extraction''': TFEsmModel,
            '''fill-mask''': TFEsmForMaskedLM,
            '''text-classification''': TFEsmForSequenceClassification,
            '''token-classification''': TFEsmForTokenClassification,
            '''zero-shot''': TFEsmForSequenceClassification,
        }
        if is_tf_available()
        else {}
    )
    lowerCAmelCase         = False
    lowerCAmelCase         = False





    def 				a__ ( self    )					->						Optional[Any]:
         UpperCAmelCase_     :				str  =     TFEsmModelTester(self    )
         UpperCAmelCase_     :				Optional[int]  =     ConfigTester(self  ,config_class=_SCREAMING_SNAKE_CASE  ,hidden_size=37    )





    def 				a__ ( self    )					->						Optional[Any]:
         self.config_tester.run_common_tests()





    def 				a__ ( self    )					->						str:
         UpperCAmelCase_     :				Optional[int]  =     self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE    )





    def 				a__ ( self    )					->						Union[str, Any]:
         UpperCAmelCase_     :				Dict  =     self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_model_as_decoder(*_SCREAMING_SNAKE_CASE    )





    def 				a__ ( self    )					->						List[Any]:
         UpperCAmelCase_     :				Any  =     self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_lm(*_SCREAMING_SNAKE_CASE    )





    def 				a__ ( self    )					->						Dict:
         UpperCAmelCase_     :				List[Any]  =     self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*_SCREAMING_SNAKE_CASE    )





    @slow
    def 				a__ ( self    )					->						List[str]:
         for model_name in TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              UpperCAmelCase_     :				str  =     TFEsmModel.from_pretrained(_SCREAMING_SNAKE_CASE    )
              self.assertIsNotNone(_SCREAMING_SNAKE_CASE    )





    @unittest.skip('''Protein models do not support embedding resizing.'''    )
    def 				a__ ( self    )					->						List[str]:
         pass





    @unittest.skip('''Protein models do not support embedding resizing.'''    )
    def 				a__ ( self    )					->						Any:
         pass





    def 				a__ ( self    )					->						Any:
         UpperCAmelCase_,       UpperCAmelCase_     :				Dict  =     self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
              UpperCAmelCase_     :				List[str]  =     model_class(_SCREAMING_SNAKE_CASE    )
              assert isinstance(model.get_input_embeddings()  ,tf.keras.layers.Layer    )
              if model_class is TFEsmForMaskedLM:
                   # Output embedding test differs from the main test because they're a matrix, not a layer
                   UpperCAmelCase_     :				Union[str, Any]  =     model.get_bias()
                   assert isinstance(_SCREAMING_SNAKE_CASE  ,_SCREAMING_SNAKE_CASE    )
                   for k, v in name.items():
                        assert isinstance(_SCREAMING_SNAKE_CASE  ,tf.Variable    )
              else:
                   UpperCAmelCase_     :				str  =     model.get_output_embeddings()
                   assert x is None
                   UpperCAmelCase_     :				Optional[Any]  =     model.get_bias()
                   assert name is None


@require_tf
class     __a(	unittest.TestCase  ):






    """simple docstring"""





    @slow
    def 				a__ ( self    )					->						Any:
         UpperCAmelCase_     :				List[Any]  =     TFEsmForMaskedLM.from_pretrained('''facebook/esm2_t6_8M_UR50D'''    )

         UpperCAmelCase_     :				Any  =     tf.constant([[0, 1, 2, 3, 4, 5]]    )
         UpperCAmelCase_     :				Optional[int]  =     model(_SCREAMING_SNAKE_CASE    )[0]
         UpperCAmelCase_     :				Optional[int]  =     [1, 6, 33]
         self.assertEqual(list(output.numpy().shape    )  ,_SCREAMING_SNAKE_CASE    )
         # compare the actual values for a slice.
         UpperCAmelCase_     :				Any  =     tf.constant(
             [
                 [
                     [8.92_15_18, -10.58_98_14, -6.4_67_13_07],
                     [-6.3_96_71_56, -13.91_13_77, -1.1_21_19_15],
                     [-7.78_12_47, -13.95_15_57, -3.74_05_92],
                 ]
             ]    )
         self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()  ,expected_slice.numpy()  ,atol=1e-2    )    )





    @slow
    def 				a__ ( self    )					->						List[str]:
         UpperCAmelCase_     :				int  =     TFEsmModel.from_pretrained('''facebook/esm2_t6_8M_UR50D'''    )

         UpperCAmelCase_     :				Optional[Any]  =     tf.constant([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]    )
         UpperCAmelCase_     :				List[Any]  =     model(_SCREAMING_SNAKE_CASE    )[0]
         # compare the actual values for a slice.
         UpperCAmelCase_     :				List[str]  =     tf.constant(
             [
                 [
                     [0.14_44_30_92, 0.54_12_53_27, 0.3_24_77_39],
                     [0.30_34_04_84, 0.00_52_66_76, 0.31_07_77_22],
                     [0.32_27_80_43, -0.24_98_70_96, 0.3_41_46_28],
                 ]
             ]    )
         self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()  ,expected_slice.numpy()  ,atol=1e-4    )    )







'''simple docstring'''



import os
import re
from shutil import copyfile
from typing import List, Optional, Tuple

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


__UpperCamelCase   :							int         =   logging.get_logger(__name__)

__UpperCamelCase   :							List[str]         =   {
    """vocab_file""": """vocab.txt""",
    """merges_file""": """bpe.codes""",
}

__UpperCamelCase   :							List[str]         =   {
    """vocab_file""": {
        """vinai/phobert-base""": """https://huggingface.co/vinai/phobert-base/resolve/main/vocab.txt""",
        """vinai/phobert-large""": """https://huggingface.co/vinai/phobert-large/resolve/main/vocab.txt""",
    },
    """merges_file""": {
        """vinai/phobert-base""": """https://huggingface.co/vinai/phobert-base/resolve/main/bpe.codes""",
        """vinai/phobert-large""": """https://huggingface.co/vinai/phobert-large/resolve/main/bpe.codes""",
    },
}

__UpperCamelCase   :							Union[str, Any]         =   {
    """vinai/phobert-base""": 256,
    """vinai/phobert-large""": 256,
}



def  __UpperCAmelCase						(					SCREAMING_SNAKE_CASE__:						int     )	->      List[str]:

   """simple docstring"""
   __a					  =     set()
   __a					  =     word[0]
   for char in word[1:]:
      pairs.add((prev_char, char)     )
      __a					  =     char

   __a					  =     set(SCREAMING_SNAKE_CASE__     )
   return pairs



class 				__SCREAMING_SNAKE_CASE							(				_lowerCAmelCase  ):
      __a	       =VOCAB_FILES_NAMES
      __a	       =PRETRAINED_VOCAB_FILES_MAP
      __a	       =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




      def __init__(	self			, lowerCamelCase			, lowerCamelCase			, lowerCamelCase="<s>"			, lowerCamelCase="</s>"			, lowerCamelCase="</s>"			, lowerCamelCase="<s>"			, lowerCamelCase="<unk>"			, lowerCamelCase="<pad>"			, lowerCamelCase="<mask>"			, **lowerCamelCase			, )				->str:



         '''simple docstring'''
         super().__init__(
             bos_token=lowerCamelCase			, eos_token=lowerCamelCase			, unk_token=lowerCamelCase			, sep_token=lowerCamelCase			, cls_token=lowerCamelCase			, pad_token=lowerCamelCase			, mask_token=lowerCamelCase			, **lowerCamelCase			, )

         __a					  =     vocab_file
         __a					  =     merges_file

         __a					  =     {}
         __a					  =     0
         __a					  =     1
         __a					  =     2
         __a					  =     3

         self.add_from_file(lowerCamelCase   )

         __a					  =     {v: k for k, v in self.encoder.items()}

         with open(lowerCamelCase			, encoding='utf-8'   ) as merges_handle:
            __a					  =     merges_handle.read().split('\n'   )[:-1]
         __a					  =     [tuple(merge.split()[:-1]   ) for merge in merges]
         __a					  =     dict(zip(lowerCamelCase			, range(len(lowerCamelCase   )   )   )   )
         __a					  =     {}




      def 			__UpperCamelCase				(	self			, lowerCamelCase			, lowerCamelCase = None   )				->List[int]:



         '''simple docstring'''

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




      def 			__UpperCamelCase				(	self			, lowerCamelCase			, lowerCamelCase = None			, lowerCamelCase = False   )				->List[int]:



         '''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 			__UpperCamelCase				(	self			, lowerCamelCase			, lowerCamelCase = None   )				->List[int]:



         '''simple docstring'''
         __a					  =     [self.sep_token_id]
         __a					  =     [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]




      @property
      def 			__UpperCamelCase				(	self   )				->Union[str, Any]:



         '''simple docstring'''
         return len(self.encoder   )




      def 			__UpperCamelCase				(	self   )				->Optional[int]:



         '''simple docstring'''
         return dict(self.encoder			, **self.added_tokens_encoder   )




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->List[str]:



         '''simple docstring'''
         if token in self.cache:
            return self.cache[token]
         __a					  =     tuple(lowerCamelCase   )
         __a					  =     tuple(list(word[:-1]   ) + [word[-1] + '</w>']   )
         __a					  =     get_pairs(lowerCamelCase   )

         if not pairs:
            return token

         while True:
            __a					  =     min(lowerCamelCase			, key=lambda lowerCamelCase   : self.bpe_ranks.get(lowerCamelCase			, float('inf'   )   )   )
            if bigram not in self.bpe_ranks:
               break
            __a  ,      __a					  =     bigram
            __a					  =     []
            __a					  =     0
            while i < len(lowerCamelCase   ):
               try:
                  __a					  =     word.index(lowerCamelCase			, lowerCamelCase   )
               except ValueError:
                  new_word.extend(word[i:]   )
                  break
               else:
                  new_word.extend(word[i:j]   )
                  __a					  =     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
            __a					  =     tuple(lowerCamelCase   )
            __a					  =     new_word
            if len(lowerCamelCase   ) == 1:
               break
            else:
               __a					  =     get_pairs(lowerCamelCase   )
         __a					  =     '@@ '.join(lowerCamelCase   )
         __a					  =     word[:-4]
         __a					  =     word
         return word




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->Dict:



         '''simple docstring'''
         __a					  =     []

         __a					  =     re.findall(r'\S+\n?'			, lowerCamelCase   )

         for token in words:
            split_tokens.extend(list(self.bpe(lowerCamelCase   ).split(' '   )   )   )
         return split_tokens




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->List[Any]:



         '''simple docstring'''
         return self.encoder.get(lowerCamelCase			, self.encoder.get(self.unk_token   )   )




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->List[Any]:



         '''simple docstring'''
         return self.decoder.get(lowerCamelCase			, self.unk_token   )




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->Dict:



         '''simple docstring'''
         __a					  =     ' '.join(lowerCamelCase   ).replace('@@ '			, ''   ).strip()
         return out_string




      def 			__UpperCamelCase				(	self			, lowerCamelCase			, lowerCamelCase = None   )				->Tuple[str]:



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

         if os.path.abspath(self.vocab_file   ) != os.path.abspath(lowerCamelCase   ):
            copyfile(self.vocab_file			, lowerCamelCase   )

         if os.path.abspath(self.merges_file   ) != os.path.abspath(lowerCamelCase   ):
            copyfile(self.merges_file			, lowerCamelCase   )

         return out_vocab_file, out_merge_file






      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->str:



         '''simple docstring'''
         if isinstance(lowerCamelCase			, lowerCamelCase   ):
            try:
               with open(lowerCamelCase			, 'r'			, encoding='utf-8'   ) as fd:
                  self.add_from_file(lowerCamelCase   )
            except FileNotFoundError as fnfe:
               raise fnfe
            except UnicodeError:
               raise Exception(F"""Incorrect encoding detected in {f}, please rebuild the dataset"""   )
            return

         __a					  =     f.readlines()
         for lineTmp in lines:
            __a					  =     lineTmp.strip()
            __a					  =     line.rfind(' '   )
            if idx == -1:
               raise ValueError('Incorrect dictionary format, expected \'<token> <cnt>\''   )
            __a					  =     line[:idx]
            __a					  =     len(self.encoder   )