'''simple docstring'''

from typing import List, Optional, Tuple

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_herbert import HerbertTokenizer


__a:			Dict	       =       logging.get_logger(__name__)

__a:			Optional[int]	       =       {"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

__a:			str	       =       {
    """vocab_file""": {
        """allegro/herbert-base-cased""": """https://huggingface.co/allegro/herbert-base-cased/resolve/main/vocab.json"""
    },
    """merges_file""": {
        """allegro/herbert-base-cased""": """https://huggingface.co/allegro/herbert-base-cased/resolve/main/merges.txt"""
    },
}

__a:			Tuple	       =       {"""allegro/herbert-base-cased""": 5_14}
__a:			Optional[int]	       =       {}



class       UpperCAmelCase  (						a__ ):





       '''simple docstring'''



       SCREAMING_SNAKE_CASE 		=   VOCAB_FILES_NAMES
       SCREAMING_SNAKE_CASE 		=   PRETRAINED_VOCAB_FILES_MAP
       SCREAMING_SNAKE_CASE 		=   PRETRAINED_INIT_CONFIGURATION
       SCREAMING_SNAKE_CASE 		=   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       SCREAMING_SNAKE_CASE 		=   HerbertTokenizer

       def __init__(						self     ,       __lowerCAmelCase=None     ,       __lowerCAmelCase=None     ,       __lowerCAmelCase=None     ,       __lowerCAmelCase="<s>"     ,       __lowerCAmelCase="<unk>"     ,       __lowerCAmelCase="<pad>"     ,       __lowerCAmelCase="<mask>"     ,       __lowerCAmelCase="</s>"     ,       **__lowerCAmelCase     ,       )  ->  Optional[Any]:
        super().__init__(
            __lowerCAmelCase     ,       __lowerCAmelCase     ,       tokenizer_file=__lowerCAmelCase     ,       cls_token=__lowerCAmelCase     ,       unk_token=__lowerCAmelCase     ,       pad_token=__lowerCAmelCase     ,       mask_token=__lowerCAmelCase     ,       sep_token=__lowerCAmelCase     ,       **__lowerCAmelCase     ,       )

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None			)  ->  List[int]:
        lowercase__    :   Union[str, Any]						= [self.cls_token_id]
        lowercase__    :   Union[str, Any]						= [self.sep_token_id]
        if token_ids_a is None:
         return cls + token_ids_a + sep

        return cls + token_ids_a + sep + token_ids_a + sep

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None     ,       __lowerCAmelCase = False			)  ->  List[int]:
        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] + ([0] * len(__lowerCAmelCase			)) + [1]

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None			)  ->  List[int]:
        lowercase__    :   Any						= [self.sep_token_id]
        lowercase__    :   Union[str, Any]						= [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			) * [0] + len(token_ids_a + sep			) * [1]


       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None			)  ->  Tuple[str]:
        lowercase__    :   Tuple						= self._tokenizer.model.save(__lowerCAmelCase     ,       name=__lowerCAmelCase			)
        return tuple(__lowerCAmelCase			)


'''simple docstring'''

import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow



@is_pipeline_test
@require_torch
class       UpperCAmelCase  (						unittest.TestCase ):





       '''simple docstring'''



       @require_torch
       def _lowerCAmelCase(						self			)  ->  int:
        lowercase__    :   str						= pipeline(
            task='''zero-shot-audio-classification'''     ,       model='''hf-internal-testing/tiny-clap-htsat-unfused'''			)
        lowercase__    :   Optional[Any]						= load_dataset('''ashraq/esc50'''			)
        lowercase__    :   Tuple						= dataset['''train''']['''audio'''][-1]['''array''']
        lowercase__    :   Optional[Any]						= audio_classifier(__lowerCAmelCase     ,       candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']			)
        self.assertEqual(
            nested_simplify(__lowerCAmelCase			)     ,       [{'''score''': 0.5_0_1, '''label''': '''Sound of a dog'''}, {'''score''': 0.4_9_9, '''label''': '''Sound of vaccum cleaner'''}]     ,       )

       @unittest.skip('''No models are available in TF'''			)
       def _lowerCAmelCase(						self			)  ->  str:
        pass

       @slow
       @require_torch
       def _lowerCAmelCase(						self			)  ->  Tuple:
        lowercase__    :   List[str]						= pipeline(
            task='''zero-shot-audio-classification'''     ,       model='''laion/clap-htsat-unfused'''     ,       )
        # This is an audio of a dog
        lowercase__    :   int						= load_dataset('''ashraq/esc50'''			)
        lowercase__    :   str						= dataset['''train''']['''audio'''][-1]['''array''']
        lowercase__    :   Any						= audio_classifier(__lowerCAmelCase     ,       candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']			)

        self.assertEqual(
            nested_simplify(__lowerCAmelCase			)     ,       [
                {'''score''': 0.9_9_9, '''label''': '''Sound of a dog'''},
                {'''score''': 0.0_0_1, '''label''': '''Sound of vaccum cleaner'''},
            ]     ,       )

        lowercase__    :   Dict						= audio_classifier([audio] * 5     ,       candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']			)
        self.assertEqual(
            nested_simplify(__lowerCAmelCase			)     ,       [
                [
                    {'''score''': 0.9_9_9, '''label''': '''Sound of a dog'''},
                    {'''score''': 0.0_0_1, '''label''': '''Sound of vaccum cleaner'''},
                ],
            ]
            * 5     ,       )
        lowercase__    :   Any						= audio_classifier(
            [audio] * 5     ,       candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']     ,       batch_size=5			)
        self.assertEqual(
            nested_simplify(__lowerCAmelCase			)     ,       [
                [
                    {'''score''': 0.9_9_9, '''label''': '''Sound of a dog'''},
                    {'''score''': 0.0_0_1, '''label''': '''Sound of vaccum cleaner'''},
                ],
            ]
            * 5     ,       )


       @unittest.skip('''No models are available in TF'''			)
       def _lowerCAmelCase(						self			)  ->  Union[str, Any]:
        pass

