


from ...processing_utils import ProcessorMixin


class     __UpperCAmelCase							(       __A							):


     """simple docstring"""
     _lowerCamelCase   =      """WhisperFeatureExtractor"""
     _lowerCamelCase   =      """WhisperTokenizer"""


     def __init__(	self  ,       __A  ,       __A    ):
        super().__init__(__A  ,       __A    )
        __a					=  self.feature_extractor
        __a					=  False


     def 	snake_case_  (	self  ,       __A=None  ,       __A=None  ,       __A=True    ):
        return self.tokenizer.get_decoder_prompt_ids(task=__A  ,       language=__A  ,       no_timestamps=__A    )


     def __call__(	self  ,       *__A  ,       **__A    ):
        # For backward compatibility
        if self._in_target_context_manager:
           return self.current_processor(*__A  ,       **__A    )

        __a					=  kwargs.pop("""audio"""  ,       __A    )
        __a					=  kwargs.pop("""sampling_rate"""  ,       __A    )
        __a					=  kwargs.pop("""text"""  ,       __A    )
        if len(__A    ) > 0:
           __a					=  args[0]
           __a					=  args[1:]

        if audio is None and text is None:
           raise ValueError("""You need to specify either an `audio` or `text` input to process."""    )

        if audio is not None:
           __a					=  self.feature_extractor(__A  ,       *__A  ,       sampling_rate=__A  ,       **__A    )
        if text is not None:
           __a					=  self.tokenizer(__A  ,       **__A    )

        if text is None:
           return inputs

        elif audio is None:
           return encodings
        else:
           __a					=  encodings["""input_ids"""]
           return inputs


     def 	snake_case_  (	self  ,       *__A  ,       **__A    ):
        return self.tokenizer.batch_decode(*__A  ,       **__A    )


     def 	snake_case_  (	self  ,       *__A  ,       **__A    ):
        return self.tokenizer.decode(*__A  ,       **__A    )


     def 	snake_case_  (	self  ,       __A  ,       __A="np"    ):
        return self.tokenizer.get_prompt_ids(__A  ,       return_tensors=__A    )






'''simple docstring'''

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

from tokenizers import pre_tokenizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if TYPE_CHECKING:
       from transformers.pipelines.conversational import Conversation


UpperCAmelCase					 =	logging.get_logger(__name__)

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

UpperCAmelCase					 =	{
    '''tokenizer_file''': {
        '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/tokenizer.json''',
    },
}

UpperCAmelCase					 =	{
    '''gpt-neox-20b''': 2048,
}


class 	lowerCAmelCase  (   A ):
       lowerCAmelCase_												=			VOCAB_FILES_NAMES
       lowerCAmelCase_												=			PRETRAINED_VOCAB_FILES_MAP
       lowerCAmelCase_												=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       lowerCAmelCase_												=			["input_ids", "attention_mask"]







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







            """simple docstring"""







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

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

            __lowercase      		=add_prefix_space







       def       snake_case (				self      :			Optional[Any]    ,   __lowercase      :			str    ,   __lowercase      :			Optional[str] = None   ):







            """simple docstring"""







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







       def       snake_case (				self      :			Optional[Any]    ,   __lowercase      :			"Conversation"   ):







            """simple docstring"""







            __lowercase      		=[]
            for is_user, text in conversation.iter_texts():
                 input_ids.extend(self.encode(__lowercase    ,   add_special_tokens=__lowercase   ) + [self.eos_token_id]   )

            if len(__lowercase   ) > self.model_max_length:
                 __lowercase      		=input_ids[-self.model_max_length :]
            return input_ids


