



from collections import UserDict
from typing import Union

import numpy as np
import requests

from ..utils import (
    add_end_docstrings,
    logging,
)
from .audio_classification import ffmpeg_read
from .base import PIPELINE_INIT_ARGS, Pipeline


UpperCAmelCase_		 =					logging.get_logger(__name__)


@add_end_docstrings(_A)
class 	lowerCamelCase__	(       _A):



 """simple docstring"""

 def __init__(    self					:					Dict			,						**__lowerCAmelCase					:					Union[str, Any]      )   ->	Dict:
    super().__init__(**__lowerCAmelCase      )

    if self.framework != "pt":
       raise ValueError(f'''The {self.__class__} is only available in PyTorch.'''      )
    # No specific FOR_XXX available yet

 def __call__(    self					:					Tuple			,						__lowerCAmelCase					:					Union[np.ndarray, bytes, str]			,						**__lowerCAmelCase					:					Union[str, Any]      )   ->	Dict:
    return super().__call__(__lowerCAmelCase			,						**__lowerCAmelCase      )

 def     snake_case_      (    self					:					Optional[Any]			,						**__lowerCAmelCase					:					Optional[int]      )   ->	Optional[int]:
    _A      =       {}
    if "candidate_labels" in kwargs:
       _A      =       kwargs['''candidate_labels''']
    if "hypothesis_template" in kwargs:
       _A      =       kwargs['''hypothesis_template''']

    return preprocess_params, {}, {}

 def     snake_case_      (    self					:					str			,						__lowerCAmelCase					:					Union[str, Any]			,						__lowerCAmelCase					:					Dict=None			,						__lowerCAmelCase					:					str="This is a sound of {}."      )   ->	Optional[Any]:
    if isinstance(__lowerCAmelCase			,						__lowerCAmelCase      ):
       if audio.startswith('''http://'''      ) or audio.startswith('''https://'''      ):
          # We need to actually check for a real protocol, otherwise it's impossible to use a local file
          # like http_huggingface_co.png
          _A      =       requests.get(__lowerCAmelCase      ).content
       else:
          with open(__lowerCAmelCase			,						'''rb'''      ) as f:
             _A      =       f.read()

    if isinstance(__lowerCAmelCase			,						__lowerCAmelCase      ):
       _A      =       ffmpeg_read(__lowerCAmelCase			,						self.feature_extractor.sampling_rate      )

    if not isinstance(__lowerCAmelCase			,						np.ndarray      ):
       raise ValueError('''We expect a numpy ndarray as input'''      )
    if len(audio.shape      ) != 1:
       raise ValueError('''We expect a single channel audio input for ZeroShotAudioClassificationPipeline'''      )

    _A      =       self.feature_extractor(
        [audio]			,						sampling_rate=self.feature_extractor.sampling_rate			,						return_tensors='''pt'''      )
    _A      =       candidate_labels
    _A      =       [hypothesis_template.format(__lowerCAmelCase      ) for x in candidate_labels]
    _A      =       self.tokenizer(__lowerCAmelCase			,						return_tensors=self.framework			,						padding=__lowerCAmelCase      )
    _A      =       [text_inputs]
    return inputs

 def     snake_case_      (    self					:					List[str]			,						__lowerCAmelCase					:					Union[str, Any]      )   ->	Dict:
    _A      =       model_inputs.pop('''candidate_labels'''      )
    _A      =       model_inputs.pop('''text_inputs'''      )
    if isinstance(text_inputs[0]			,						__lowerCAmelCase      ):
       _A      =       text_inputs[0]
    else:
       # Batching case.
       _A      =       text_inputs[0][0]

    _A      =       self.model(**__lowerCAmelCase			,						**__lowerCAmelCase      )

    _A      =       {
        '''candidate_labels''': candidate_labels,
        '''logits''': outputs.logits_per_audio,
    }
    return model_outputs

 def     snake_case_      (    self					:					Tuple			,						__lowerCAmelCase					:					List[str]      )   ->	Tuple:
    _A      =       model_outputs.pop('''candidate_labels'''      )
    _A      =       model_outputs['''logits'''][0]

    if self.framework == "pt":
       _A      =       logits.softmax(dim=0      )
       _A      =       probs.tolist()
    else:
       raise ValueError('''`tf` framework not supported.'''      )

    _A      =       [
        {'''score''': score, '''label''': candidate_label}
        for score, candidate_label in sorted(zip(__lowerCAmelCase			,						__lowerCAmelCase      )			,						key=lambda __lowerCAmelCase      : -x[0]      )
    ]
    return result




"""simple docstring"""




from collections.abc import Generator







def 				_UpperCAmelCase		(							):





		"""simple docstring"""




		lowerCAmelCase__ ,       lowerCAmelCase__   = 0, 1
		while True:
				lowerCAmelCase__ ,       lowerCAmelCase__   = b, a + b
				yield b







def 				_UpperCAmelCase		(							lowerCamelCase__ = 1000  ):





		"""simple docstring"""




		lowerCAmelCase__   = 1
		lowerCAmelCase__   = fibonacci_generator()
		while len(str(next(lowerCamelCase__  )  )  ) < n:
				answer += 1
		return answer + 1


if __name__ == "__main__":
			print(solution(int(str(input()).strip())))




