'''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 		__A       (unittest.TestCase   ):






       @require_torch
       def 			_snake_case						(      self      ):
              __UpperCAmelCase  :				Union[str, Any]       				=		pipeline(
                  task="zero-shot-audio-classification"				,     model="hf-internal-testing/tiny-clap-htsat-unfused"      )
              __UpperCAmelCase  :				Optional[int]       				=		load_dataset("ashraq/esc50"      )
              __UpperCAmelCase  :				Union[str, Any]       				=		dataset["train"]["audio"][-1]["array"]
              __UpperCAmelCase  :				List[Any]       				=		audio_classifier(UpperCamelCase_				,     candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]      )
              self.assertEqual(
                  nested_simplify(UpperCamelCase_      )				,     [{"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 			_snake_case						(      self      ):
              pass






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

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

              __UpperCAmelCase  :				Optional[Any]       				=		audio_classifier([audio] * 5				,     candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]      )
              self.assertEqual(
                  nested_simplify(UpperCamelCase_      )				,     [
                      [
                          {"score": 0.9_9_9, "label": "Sound of a dog"},
                          {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
                      ],
                  ]
                  * 5				,     )
              __UpperCAmelCase  :				Optional[int]       				=		audio_classifier(
                  [audio] * 5				,     candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]				,     batch_size=5      )
              self.assertEqual(
                  nested_simplify(UpperCamelCase_      )				,     [
                      [
                          {"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 			_snake_case						(      self      ):
              pass







'''simple docstring'''




def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       float:





       """simple docstring"""


       if discount_rate < 0:
              raise ValueError("Discount rate cannot be negative"						)
       if not cash_flows:
              raise ValueError("Cash flows list cannot be empty"						)
       __UpperCAmelCase  :				Tuple       				=		sum(
           cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(lowerCamelCase__						)						)
       return round(lowerCamelCase__							,    ndigits=2						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()






