import importlib
import inspect
import json
import os
from collections import OrderedDict

# Build the list of all feature extractors
from ...configuration_utils import PretrainedConfig
from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code
from ...feature_extraction_utils import FeatureExtractionMixin
from ...image_processing_utils import ImageProcessingMixin
from ...tokenization_utils import TOKENIZER_CONFIG_FILE
from ...utils import FEATURE_EXTRACTOR_NAME, get_file_from_repo, logging
from .auto_factory import _LazyAutoMapping
from .configuration_auto import (
    CONFIG_MAPPING_NAMES,
    AutoConfig,
    model_type_to_module_name,
    replace_list_option_in_docstrings,
)
from .feature_extraction_auto import AutoFeatureExtractor
from .image_processing_auto import AutoImageProcessor
from .tokenization_auto import AutoTokenizer


UpperCAmelCase      		=					logging.get_logger(__name__)

UpperCAmelCase      		=					OrderedDict(
    [
        ('''align''', '''AlignProcessor'''),
        ('''altclip''', '''AltCLIPProcessor'''),
        ('''bark''', '''BarkProcessor'''),
        ('''blip''', '''BlipProcessor'''),
        ('''blip-2''', '''Blip2Processor'''),
        ('''bridgetower''', '''BridgeTowerProcessor'''),
        ('''chinese_clip''', '''ChineseCLIPProcessor'''),
        ('''clap''', '''ClapProcessor'''),
        ('''clip''', '''CLIPProcessor'''),
        ('''clipseg''', '''CLIPSegProcessor'''),
        ('''flava''', '''FlavaProcessor'''),
        ('''git''', '''GitProcessor'''),
        ('''groupvit''', '''CLIPProcessor'''),
        ('''hubert''', '''Wav2Vec2Processor'''),
        ('''instructblip''', '''InstructBlipProcessor'''),
        ('''layoutlmv2''', '''LayoutLMv2Processor'''),
        ('''layoutlmv3''', '''LayoutLMv3Processor'''),
        ('''markuplm''', '''MarkupLMProcessor'''),
        ('''mctct''', '''MCTCTProcessor'''),
        ('''mgp-str''', '''MgpstrProcessor'''),
        ('''oneformer''', '''OneFormerProcessor'''),
        ('''owlvit''', '''OwlViTProcessor'''),
        ('''pix2struct''', '''Pix2StructProcessor'''),
        ('''sam''', '''SamProcessor'''),
        ('''sew''', '''Wav2Vec2Processor'''),
        ('''sew-d''', '''Wav2Vec2Processor'''),
        ('''speech_to_text''', '''Speech2TextProcessor'''),
        ('''speech_to_text_2''', '''Speech2Text2Processor'''),
        ('''speecht5''', '''SpeechT5Processor'''),
        ('''trocr''', '''TrOCRProcessor'''),
        ('''tvlt''', '''TvltProcessor'''),
        ('''unispeech''', '''Wav2Vec2Processor'''),
        ('''unispeech-sat''', '''Wav2Vec2Processor'''),
        ('''vilt''', '''ViltProcessor'''),
        ('''vision-text-dual-encoder''', '''VisionTextDualEncoderProcessor'''),
        ('''wav2vec2''', '''Wav2Vec2Processor'''),
        ('''wav2vec2-conformer''', '''Wav2Vec2Processor'''),
        ('''wavlm''', '''Wav2Vec2Processor'''),
        ('''whisper''', '''WhisperProcessor'''),
        ('''xclip''', '''XCLIPProcessor'''),
    ]
)

UpperCAmelCase      		=					_LazyAutoMapping(CONFIG_MAPPING_NAMES, PROCESSOR_MAPPING_NAMES)


def SCREAMING_SNAKE_CASE					(  lowercase_:						str					):
       for module_name, processors in PROCESSOR_MAPPING_NAMES.items():
              if class_name in processors:
                     _UpperCamelCase  :							Dict	    =	model_type_to_module_name(lowercase_					)

                     _UpperCamelCase  :							Any	    =	importlib.import_module(F".{module_name}"		,    'transformers.models'					)
                     try:
                            return getattr(lowercase_		,    lowercase_					)
                     except AttributeError:
                            continue

       for processor in PROCESSOR_MAPPING._extra_content.values():
              if getattr(lowercase_		,    '__name__'		,    lowercase_					) == class_name:
                     return processor

    # We did not fine the class, but maybe it's because a dep is missing. In that case, the class will be in the main
    # init and we return the proper dummy to get an appropriate error message.
       _UpperCamelCase  :							Dict	    =	importlib.import_module('transformers'					)
       if hasattr(lowercase_		,    lowercase_					):
              return getattr(lowercase_		,    lowercase_					)

       return None





class  __lowerCAmelCase	:



 '''simple docstring'''

 def __init__(      self							:		Union[str, Any]	)			->				Optional[Any]:
        raise EnvironmentError(
            'AutoProcessor is designed to be instantiated '
            'using the `AutoProcessor.from_pretrained(pretrained_model_name_or_path)` method.'	)

 @classmethod
 @replace_list_option_in_docstrings(lowerCamelCase	)
 def        __snake_case       (      cls							:		Optional[int]							,      lowerCamelCase							:		str							,      **lowerCamelCase							:		int	)			->				int:
        _UpperCamelCase  :							Union[str, Any]	    =	kwargs.pop('config'							,      lowerCamelCase	)
        _UpperCamelCase  :							Dict	    =	kwargs.pop('trust_remote_code'							,      lowerCamelCase	)
        _UpperCamelCase  :							List[Any]	    =	True

        _UpperCamelCase  :							List[Any]	    =	None
        _UpperCamelCase  :							str	    =	None

        # First, let's see if we have a preprocessor config.
        # Filter the kwargs for `get_file_from_repo`.
        _UpperCamelCase  :							Tuple	    =	{
            key: kwargs[key] for key in inspect.signature(lowerCamelCase	).parameters.keys() if key in kwargs
        }
        # Let's start by checking whether the processor class is saved in an image processor
        _UpperCamelCase  :							Optional[Any]	    =	get_file_from_repo(
            lowerCamelCase							,      lowerCamelCase							,      **lowerCamelCase	)
        if preprocessor_config_file is not None:
               _UpperCamelCase    ,   _UpperCamelCase  :							str	    =	ImageProcessingMixin.get_image_processor_dict(lowerCamelCase							,      **lowerCamelCase	)
               _UpperCamelCase  :							Tuple	    =	config_dict.get('processor_class'							,      lowerCamelCase	)
               if "AutoProcessor" in config_dict.get('auto_map'							,      {}	):
                      _UpperCamelCase  :							Tuple	    =	config_dict['auto_map']['AutoProcessor']

        # If not found, let's check whether the processor class is saved in a feature extractor config
        if preprocessor_config_file is not None and processor_class is None:
               _UpperCamelCase    ,   _UpperCamelCase  :							Dict	    =	FeatureExtractionMixin.get_feature_extractor_dict(lowerCamelCase							,      **lowerCamelCase	)
               _UpperCamelCase  :							Tuple	    =	config_dict.get('processor_class'							,      lowerCamelCase	)
               if "AutoProcessor" in config_dict.get('auto_map'							,      {}	):
                      _UpperCamelCase  :							Dict	    =	config_dict['auto_map']['AutoProcessor']

        if processor_class is None:
               # Next, let's check whether the processor class is saved in a tokenizer
               _UpperCamelCase  :							List[str]	    =	get_file_from_repo(
                   lowerCamelCase							,      lowerCamelCase							,      **lowerCamelCase	)
               if tokenizer_config_file is not None:
                      with open(lowerCamelCase							,      encoding='utf-8'	) as reader:
                             _UpperCamelCase  :							Tuple	    =	json.load(lowerCamelCase	)

                      _UpperCamelCase  :							Tuple	    =	config_dict.get('processor_class'							,      lowerCamelCase	)
                      if "AutoProcessor" in config_dict.get('auto_map'							,      {}	):
                             _UpperCamelCase  :							int	    =	config_dict['auto_map']['AutoProcessor']

        if processor_class is None:
               # Otherwise, load config, if it can be loaded.
               if not isinstance(lowerCamelCase							,      lowerCamelCase	):
                      _UpperCamelCase  :							Any	    =	AutoConfig.from_pretrained(
                          lowerCamelCase							,      trust_remote_code=lowerCamelCase							,      **lowerCamelCase	)

               # And check if the config contains the processor class.
               _UpperCamelCase  :							Tuple	    =	getattr(lowerCamelCase							,      'processor_class'							,      lowerCamelCase	)
               if hasattr(lowerCamelCase							,      'auto_map'	) and "AutoProcessor" in config.auto_map:
                      _UpperCamelCase  :							int	    =	config.auto_map['AutoProcessor']

        if processor_class is not None:
               _UpperCamelCase  :							int	    =	processor_class_from_name(lowerCamelCase	)

        _UpperCamelCase  :							Optional[Any]	    =	processor_auto_map is not None
        _UpperCamelCase  :							Tuple	    =	processor_class is not None or type(lowerCamelCase	) in PROCESSOR_MAPPING
        _UpperCamelCase  :							int	    =	resolve_trust_remote_code(
            lowerCamelCase							,      lowerCamelCase							,      lowerCamelCase							,      lowerCamelCase	)

        if has_remote_code and trust_remote_code:
               _UpperCamelCase  :							Any	    =	get_class_from_dynamic_module(
                   lowerCamelCase							,      lowerCamelCase							,      **lowerCamelCase	)
               _UpperCamelCase  :							Any	    =	kwargs.pop('code_revision'							,      lowerCamelCase	)
               if os.path.isdir(lowerCamelCase	):
                      processor_class.register_for_auto_class()
               return processor_class.from_pretrained(
                   lowerCamelCase							,      trust_remote_code=lowerCamelCase							,      **lowerCamelCase	)
        elif processor_class is not None:
               return processor_class.from_pretrained(
                   lowerCamelCase							,      trust_remote_code=lowerCamelCase							,      **lowerCamelCase	)
        # Last try: we use the PROCESSOR_MAPPING.
        elif type(lowerCamelCase	) in PROCESSOR_MAPPING:
               return PROCESSOR_MAPPING[type(lowerCamelCase	)].from_pretrained(lowerCamelCase							,      **lowerCamelCase	)

        # At this stage, there doesn't seem to be a `Processor` class available for this model, so let's try a
        # tokenizer.
        try:
               return AutoTokenizer.from_pretrained(
                   lowerCamelCase							,      trust_remote_code=lowerCamelCase							,      **lowerCamelCase	)
        except Exception:
               try:
                      return AutoImageProcessor.from_pretrained(
                          lowerCamelCase							,      trust_remote_code=lowerCamelCase							,      **lowerCamelCase	)
               except Exception:
                      pass

               try:
                      return AutoFeatureExtractor.from_pretrained(
                          lowerCamelCase							,      trust_remote_code=lowerCamelCase							,      **lowerCamelCase	)
               except Exception:
                      pass

        raise ValueError(
            f"Unrecognized processing class in {pretrained_model_name_or_path}. Can't instantiate a processor, a "
            'tokenizer, an image processor or a feature extractor for this model. Make sure the repository contains'
            'the files of at least one of those processing classes.'	)

 @staticmethod
 def        __snake_case       (      lowerCamelCase							:		Any							,      lowerCamelCase							:		List[str]	)			->				Any:
        PROCESSOR_MAPPING.register(lowerCamelCase							,      lowerCamelCase	)




import json
import os
from functools import lru_cache
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np
import regex as re

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 ...tokenization_utils import AddedToken, PreTrainedTokenizer


UpperCAmelCase      		=					logging.get_logger(__name__)

UpperCAmelCase      		=					{
    '''vocab_file''': '''vocab.json''',
    '''merges_file''': '''merges.txt''',
}

UpperCAmelCase      		=					{
    '''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''',
    },
}

UpperCAmelCase      		=					{
    '''Salesforce/codegen-350M-mono''': 20_48,
}


@lru_cache()
def SCREAMING_SNAKE_CASE					(  ):
       _UpperCamelCase  :							Union[str, Any]	    =	(
           list(range(ord('!'					)		,    ord('~'					) + 1					)					) + list(range(ord('¡'					)		,    ord('¬'					) + 1					)					) + list(range(ord('®'					)		,    ord('ÿ'					) + 1					)					)
       )
       _UpperCamelCase  :							List[Any]	    =	bs[:]
       _UpperCamelCase  :							Optional[Any]	    =	0
       for b in range(2**8					):
              if b not in bs:
                     bs.append(lowercase_					)
                     cs.append(2**8 + n					)
                     n += 1
       _UpperCamelCase  :							int	    =	[chr(lowercase_					) for n in cs]
       return dict(zip(lowercase_		,    lowercase_					)					)


def SCREAMING_SNAKE_CASE					(  lowercase_:						Optional[int]					):
       _UpperCamelCase  :							Any	    =	set()
       _UpperCamelCase  :							str	    =	word[0]
       for char in word[1:]:
              pairs.add((prev_char, char)					)
              _UpperCamelCase  :							Optional[int]	    =	char
       return pairs





class  __lowerCAmelCase	(							a_    ):



 '''simple docstring'''
 _lowerCamelCase    :						int					     =			VOCAB_FILES_NAMES
 _lowerCamelCase    :						str					     =			PRETRAINED_VOCAB_FILES_MAP
 _lowerCamelCase    :						str					     =			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 _lowerCamelCase    :						Dict					     =			['input_ids', 'attention_mask']

 def __init__(      self							:		List[str]							,      lowerCamelCase							:		List[str]							,      lowerCamelCase							:		Tuple							,      lowerCamelCase							:		Union[str, Any]="replace"							,      lowerCamelCase							:		List[str]="<|endoftext|>"							,      lowerCamelCase							:		Union[str, Any]="<|endoftext|>"							,      lowerCamelCase							:		int="<|endoftext|>"							,      lowerCamelCase							:		str=None							,      lowerCamelCase							:		int=False							,      lowerCamelCase							:		Optional[int]=False							,      **lowerCamelCase							:		List[str]							,      )			->				Any:
        _UpperCamelCase  :							List[Any]	    =	AddedToken(lowerCamelCase							,      lstrip=lowerCamelCase							,      rstrip=lowerCamelCase	) if isinstance(lowerCamelCase							,      lowerCamelCase	) else bos_token
        _UpperCamelCase  :							Union[str, Any]	    =	AddedToken(lowerCamelCase							,      lstrip=lowerCamelCase							,      rstrip=lowerCamelCase	) if isinstance(lowerCamelCase							,      lowerCamelCase	) else eos_token
        _UpperCamelCase  :							str	    =	AddedToken(lowerCamelCase							,      lstrip=lowerCamelCase							,      rstrip=lowerCamelCase	) if isinstance(lowerCamelCase							,      lowerCamelCase	) else unk_token
        _UpperCamelCase  :							List[str]	    =	AddedToken(lowerCamelCase							,      lstrip=lowerCamelCase							,      rstrip=lowerCamelCase	) if isinstance(lowerCamelCase							,      lowerCamelCase	) else pad_token
        super().__init__(
            errors=lowerCamelCase							,      unk_token=lowerCamelCase							,      bos_token=lowerCamelCase							,      eos_token=lowerCamelCase							,      pad_token=lowerCamelCase							,      add_prefix_space=lowerCamelCase							,      add_bos_token=lowerCamelCase							,      **lowerCamelCase							,      )
        _UpperCamelCase  :							str	    =	add_bos_token

        with open(lowerCamelCase							,      encoding='utf-8'	) as vocab_handle:
               _UpperCamelCase  :							Tuple	    =	json.load(lowerCamelCase	)
        _UpperCamelCase  :							List[str]	    =	{v: k for k, v in self.encoder.items()}
        _UpperCamelCase  :							Any	    =	errors  # how to handle errors in decoding
        _UpperCamelCase  :							int	    =	bytes_to_unicode()
        _UpperCamelCase  :							Union[str, Any]	    =	{v: k for k, v in self.byte_encoder.items()}
        with open(lowerCamelCase							,      encoding='utf-8'	) as merges_handle:
               _UpperCamelCase  :							Optional[Any]	    =	merges_handle.read().split('\n'	)[1:-1]
        _UpperCamelCase  :							Optional[Any]	    =	[tuple(merge.split()	) for merge in bpe_merges]
        _UpperCamelCase  :							List[str]	    =	dict(zip(lowerCamelCase							,      range(len(lowerCamelCase	)	)	)	)
        _UpperCamelCase  :							Tuple	    =	{}
        _UpperCamelCase  :							Union[str, Any]	    =	add_prefix_space

        # Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
        _UpperCamelCase  :							Union[str, Any]	    =	re.compile(r'\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+'	)

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

 def        __snake_case       (      self							:		Dict	)			->				int:
        return dict(self.encoder							,      **self.added_tokens_encoder	)

 def        __snake_case       (      self							:		List[Any]							,      lowerCamelCase							:		List[str]	)			->				Dict:
        if token in self.cache:
               return self.cache[token]
        _UpperCamelCase  :							List[str]	    =	tuple(lowerCamelCase	)
        _UpperCamelCase  :							Optional[Any]	    =	get_pairs(lowerCamelCase	)

        if not pairs:
               return token

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

 def        __snake_case       (      self							:		str							,      lowerCamelCase							:		Dict							,      lowerCamelCase							:		Tuple=None	)			->				Dict:
        if self.add_bos_token:
               _UpperCamelCase  :							Dict	    =	[self.bos_token_id]
        else:
               _UpperCamelCase  :							Union[str, Any]	    =	[]

        _UpperCamelCase  :							str	    =	bos_token_ids + token_ids_a

        if token_ids_a is None:
               return output

        return output + bos_token_ids + token_ids_a

 def        __snake_case       (      self							:		int							,      lowerCamelCase							:		int	)			->				Optional[Any]:
        _UpperCamelCase  :							List[str]	    =	[]
        for token in re.findall(self.pat							,      lowerCamelCase	):
               _UpperCamelCase  :							Optional[int]	    =	''.join(
                   self.byte_encoder[b] for b in token.encode('utf-8'	)	)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
               bpe_tokens.extend(bpe_token for bpe_token in self.bpe(lowerCamelCase	).split(' '	)	)
        return bpe_tokens

 def        __snake_case       (      self							:		Any							,      lowerCamelCase							:		Union[str, Any]	)			->				Any:
        return self.encoder.get(lowerCamelCase							,      self.encoder.get(self.unk_token	)	)

 def        __snake_case       (      self							:		int							,      lowerCamelCase							:		List[Any]	)			->				Union[str, Any]:
        return self.decoder.get(lowerCamelCase	)

 def        __snake_case       (      self							:		List[str]							,      lowerCamelCase							:		Any	)			->				Optional[Any]:
        _UpperCamelCase  :							int	    =	''.join(lowerCamelCase	)
        _UpperCamelCase  :							Union[str, Any]	    =	bytearray([self.byte_decoder[c] for c in text]	).decode('utf-8'							,      errors=self.errors	)
        return text

 def        __snake_case       (      self							:		Dict							,      lowerCamelCase							:		str							,      lowerCamelCase							:		Optional[str] = None	)			->				Tuple[str]:
        if not os.path.isdir(lowerCamelCase	):
               logger.error(f"Vocabulary path ({save_directory}) should be a directory"	)
               return
        _UpperCamelCase  :							str	    =	os.path.join(
            lowerCamelCase							,      (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']	)
        _UpperCamelCase  :							Optional[Any]	    =	os.path.join(
            lowerCamelCase							,      (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['merges_file']	)

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

        _UpperCamelCase  :							Optional[Any]	    =	0
        with open(lowerCamelCase							,      'w'							,      encoding='utf-8'	) as writer:
               writer.write('#version: 0.2\n'	)
               for bpe_tokens, token_index in sorted(self.bpe_ranks.items()							,      key=lambda lowerCamelCase	: kv[1]	):
                      if index != token_index:
                             logger.warning(
                                 f"Saving vocabulary to {merge_file}: BPE merge indices are not consecutive."
                                 ' Please check that the tokenizer is not corrupted!'	)
                             _UpperCamelCase  :							str	    =	token_index
                      writer.write(' '.join(lowerCamelCase	) + '\n'	)
                      index += 1

        return vocab_file, merge_file

 def        __snake_case       (      self							:		List[str]							,      lowerCamelCase							:		Union[str, Any]							,      lowerCamelCase							:		int=False							,      **lowerCamelCase							:		int	)			->				List[Any]:
        _UpperCamelCase  :							Dict	    =	kwargs.pop('add_prefix_space'							,      self.add_prefix_space	)
        if is_split_into_words or add_prefix_space:
               _UpperCamelCase  :							Any	    =	' ' + text
        return (text, kwargs)

 def        __snake_case       (      self							:		str							,      lowerCamelCase							:		Union[int, List[int], "np.ndarray", "torch.Tensor", "tf.Tensor"]							,      lowerCamelCase							:		bool = False							,      lowerCamelCase							:		bool = None							,      lowerCamelCase							:		Optional[List[str]] = None							,      **lowerCamelCase							:		List[str]							,      )			->				str:
        _UpperCamelCase  :							Optional[int]	    =	super()._decode(
            token_ids=lowerCamelCase							,      skip_special_tokens=lowerCamelCase							,      clean_up_tokenization_spaces=lowerCamelCase							,      **lowerCamelCase							,      )

        if truncate_before_pattern is not None and len(lowerCamelCase	) > 0:
               _UpperCamelCase  :							Optional[Any]	    =	self.truncate(lowerCamelCase							,      lowerCamelCase	)

        return decoded_text

 def        __snake_case       (      self							:		Optional[int]							,      lowerCamelCase							:		Union[str, Any]							,      lowerCamelCase							:		Any	)			->				Optional[int]:
        def find_re(lowerCamelCase							:		Any							,      lowerCamelCase							:		List[Any]							,      lowerCamelCase							:		str	):
               _UpperCamelCase  :							Optional[int]	    =	pattern.search(lowerCamelCase							,      lowerCamelCase	)
               return m.start() if m else -1

        _UpperCamelCase  :							Dict	    =	[re.compile(lowerCamelCase							,      re.MULTILINE	) for pattern in truncate_before_pattern]

        _UpperCamelCase  :							Union[str, Any]	    =	list(re.finditer('^print'							,      lowerCamelCase							,      re.MULTILINE	)	)

        if len(lowerCamelCase	) > 1:
               _UpperCamelCase  :							Tuple	    =	completion[: prints[1].start()]

        _UpperCamelCase  :							Union[str, Any]	    =	list(re.finditer('^def'							,      lowerCamelCase							,      re.MULTILINE	)	)

        if len(lowerCamelCase	) > 1:
               _UpperCamelCase  :							List[str]	    =	completion[: defs[1].start()]

        _UpperCamelCase  :							Tuple	    =	0

        _UpperCamelCase  :							List[str]	    =	[
            pos for pos in [find_re(lowerCamelCase							,      lowerCamelCase							,      lowerCamelCase	) for terminal in terminals] if pos != -1
        ]

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



