
"""simple docstring"""



import json
import re
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np

from ...utils import is_tf_available, is_torch_available, logging


if TYPE_CHECKING:
 if is_torch_available():
  import torch
 if is_tf_available():
  import tensorflow as tf

from tokenizers import pre_tokenizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_codegen import CodeGenTokenizer


a       :						Optional[int]       		=		logging.get_logger(__name__)

a       :						Optional[Any]       		=		{'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

a       :						List[str]       		=		{
    '''vocab_file''': {
        '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/vocab.json''',
    },
    '''merges_file''': {
        '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/merges.txt''',
    },
    '''tokenizer_file''': {
        '''Salesforce/codegen-350M-mono''': (
            '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/tokenizer.json'''
        ),
    },
}

a       :						Optional[Any]       		=		{
    '''Salesforce/codegen-350M-mono''': 2_0_4_8,
}




class 		a_    (			_UpperCAmelCase						):
    a   :					List[Any]			     =					VOCAB_FILES_NAMES
    a   :					int			     =					PRETRAINED_VOCAB_FILES_MAP
    a   :					List[Any]			     =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    a   :					Dict			     =					['input_ids', 'attention_mask']
    a   :					int			     =					CodeGenTokenizer







    def __init__(      self      :							str  ,       __UpperCamelCase      :							Tuple=None  ,       __UpperCamelCase      :							Any=None  ,       __UpperCamelCase      :							List[str]=None  ,       __UpperCamelCase      :							Dict="<|endoftext|>"  ,       __UpperCamelCase      :							int="<|endoftext|>"  ,       __UpperCamelCase      :							Tuple="<|endoftext|>"  ,       __UpperCamelCase      :							List[str]=False  ,       **__UpperCamelCase      :							Tuple  ,       )		->Union[str, Any]:






        '''simple docstring'''






        super().__init__(
            __UpperCamelCase  ,       __UpperCamelCase  ,       tokenizer_file=__UpperCamelCase  ,       unk_token=__UpperCamelCase  ,       bos_token=__UpperCamelCase  ,       eos_token=__UpperCamelCase  ,       add_prefix_space=__UpperCamelCase  ,       **__UpperCamelCase  ,       )

        if kwargs.pop("""add_bos_token"""  ,       __UpperCamelCase  ):
            _UpperCAmelCase        = kwargs.pop("""name_or_path"""  ,       """"""  )
            raise ValueError(
                """Currenty GPT2's fast tokenizer does NOT support adding a BOS token."""
                """Instead you should use GPT2's slow tokenizer class `CodeGenTokenizer` as follows: \n"""
                f"""`CodeGenTokenizer.from_pretrained('{model_id}')`\nor\n"""
                f"""`AutoTokenizer.from_pretrained('{model_id}', use_fast=False)`\n"""
                """This issue will be fixed soon, see: https://github.com/huggingface/tokenizers/pull/1005."""
                """ so that the fast tokenizer works correctly."""  )

        _UpperCAmelCase        = json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()  )
        if pre_tok_state.get("""add_prefix_space"""  ,       __UpperCamelCase  ) != add_prefix_space:
            _UpperCAmelCase        = getattr(__UpperCamelCase  ,       pre_tok_state.pop("""type"""  )  )
            _UpperCAmelCase        = add_prefix_space
            _UpperCAmelCase        = pre_tok_class(**__UpperCamelCase  )

        _UpperCAmelCase        = add_prefix_space







    def   _snake_case       (      self      :							Any  ,       *__UpperCamelCase      :							List[str]  ,       **__UpperCamelCase      :							Dict  )		->BatchEncoding:






        '''simple docstring'''






        _UpperCAmelCase        = kwargs.get("""is_split_into_words"""  ,       __UpperCamelCase  )
        assert self.add_prefix_space or not is_split_into_words, (
            f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
            "to use it with pretokenized inputs."
        )

        return super()._batch_encode_plus(*__UpperCamelCase  ,       **__UpperCamelCase  )







    def   _snake_case       (      self      :							Optional[Any]  ,       *__UpperCamelCase      :							Dict  ,       **__UpperCamelCase      :							Union[str, Any]  )		->BatchEncoding:






        '''simple docstring'''






        _UpperCAmelCase        = kwargs.get("""is_split_into_words"""  ,       __UpperCamelCase  )

        assert self.add_prefix_space or not is_split_into_words, (
            f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
            "to use it with pretokenized inputs."
        )

        return super()._encode_plus(*__UpperCamelCase  ,       **__UpperCamelCase  )







    def   _snake_case       (      self      :							Any  ,       __UpperCamelCase      :							str  ,       __UpperCamelCase      :							Optional[str] = None  )		->Tuple[str]:






        '''simple docstring'''






        _UpperCAmelCase        = self._tokenizer.model.save(__UpperCamelCase  ,       name=__UpperCamelCase  )
        return tuple(__UpperCamelCase  )







    def   _snake_case       (      self      :							Any  ,       __UpperCamelCase      :							Union[int, List[int], "np.ndarray", "torch.Tensor", "tf.Tensor"]  ,       __UpperCamelCase      :							bool = False  ,       __UpperCamelCase      :							bool = None  ,       __UpperCamelCase      :							Optional[List[str]] = None  ,       **__UpperCamelCase      :							str  ,       )		->str:






        '''simple docstring'''






        _UpperCAmelCase        = super().decode(
            token_ids=__UpperCamelCase  ,       skip_special_tokens=__UpperCamelCase  ,       clean_up_tokenization_spaces=__UpperCamelCase  ,       **__UpperCamelCase  ,       )

        if truncate_before_pattern is not None and len(__UpperCamelCase  ) > 0:
            _UpperCAmelCase        = self.truncate(__UpperCamelCase  ,       __UpperCamelCase  )

        return decoded_text







    def   _snake_case       (      self      :							Dict  ,       __UpperCamelCase      :							List[str]  ,       __UpperCamelCase      :							Dict  )		->Optional[Any]:






        '''simple docstring'''






        def find_re(__UpperCamelCase      :							Any  ,       __UpperCamelCase      :							Optional[Any]  ,       __UpperCamelCase      :							Optional[Any]  ):
            _UpperCAmelCase        = pattern.search(__UpperCamelCase  ,       __UpperCamelCase  )
            return m.start() if m else -1

        _UpperCAmelCase        = [re.compile(__UpperCamelCase  ,       re.MULTILINE  ) for pattern in truncate_before_pattern]

        _UpperCAmelCase        = list(re.finditer("""^print"""  ,       __UpperCamelCase  ,       re.MULTILINE  )  )

        if len(__UpperCamelCase  ) > 1:
            _UpperCAmelCase        = completion[: prints[1].start()]

        _UpperCAmelCase        = list(re.finditer("""^def"""  ,       __UpperCamelCase  ,       re.MULTILINE  )  )

        if len(__UpperCamelCase  ) > 1:
            _UpperCAmelCase        = completion[: defs[1].start()]

        _UpperCAmelCase        = 0

        _UpperCAmelCase        = [
            pos for pos in [find_re(__UpperCamelCase  ,       __UpperCamelCase  ,       __UpperCamelCase  ) for terminal in terminals] if pos != -1
        ]

        if len(__UpperCamelCase  ) > 0:
            return completion[: min(__UpperCamelCase  )]
        else:
            return completion

"""simple docstring"""



import os
from math import logaa


def 			_UpperCamelCase						(    _A = "base_exp.txt"   )     ->	int:





    """simple docstring"""

    _UpperCAmelCase        = 0
    _UpperCAmelCase        = 0
    for i, line in enumerate(open(os.path.join(os.path.dirname(_A   )       ,   _A   )   )   ):
        _UpperCAmelCase     ,_UpperCAmelCase        = list(map(_A       ,   line.split(""","""   )   )   )
        if x * logaa(_A   ) > largest:
            _UpperCAmelCase        = x * logaa(_A   )
            _UpperCAmelCase        = i + 1
    return result


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