


import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput







@dataclass
class       _lowercase			(							A__):


       """simple docstring"""




       A__ 						=      42
       A__ 						=      None
       A__ 						=      None







class       _lowercase			(							unittest.TestCase):


       """simple docstring"""




       def 						lowerCAmelCase					(       self							:      str	):


             '''simple docstring'''



             lowerCamelCase__		:    Optional[int]   =  ModelOutputTest(a=30	)
             self.assertEqual(x.a ,				30	)
             self.assertIsNone(x.b	)
             self.assertIsNone(x.c	)
             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    Union[str, Any]   =  x.d





       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    Any   =  ModelOutputTest(a=30 ,				b=10	)
             self.assertEqual(x[0] ,				30	)
             self.assertEqual(x[1] ,				10	)
             self.assertEqual(x[:2] ,				(30, 10)	)
             self.assertEqual(x[:] ,				(30, 10)	)

             lowerCamelCase__		:    List[Any]   =  ModelOutputTest(a=30 ,				c=10	)
             self.assertEqual(x[0] ,				30	)
             self.assertEqual(x[1] ,				10	)
             self.assertEqual(x[:2] ,				(30, 10)	)
             self.assertEqual(x[:] ,				(30, 10)	)





       def 						lowerCAmelCase					(       self							:      Dict	):


             '''simple docstring'''



             lowerCamelCase__		:    str   =  ModelOutputTest(a=30 ,				b=10	)
             self.assertEqual(x["a"] ,				30	)
             self.assertEqual(x["b"] ,				10	)
             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    Tuple   =  x["c"]

             lowerCamelCase__		:    Optional[int]   =  ModelOutputTest(a=30 ,				c=10	)
             self.assertEqual(x["a"] ,				30	)
             self.assertEqual(x["c"] ,				10	)
             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    List[Any]   =  x["b"]





       def 						lowerCAmelCase					(       self							:      Tuple	):


             '''simple docstring'''



             lowerCamelCase__		:    Union[str, Any]   =  ModelOutputTest(a=30	)
             self.assertEqual(list(x.keys()	) ,				["a"]	)
             self.assertEqual(list(x.values()	) ,				[30]	)
             self.assertEqual(list(x.items()	) ,				[("a", 30)]	)
             self.assertEqual(list(__lowerCamelCase	) ,				["a"]	)

             lowerCamelCase__		:    Optional[int]   =  ModelOutputTest(a=30 ,				b=10	)
             self.assertEqual(list(x.keys()	) ,				["a", "b"]	)
             self.assertEqual(list(x.values()	) ,				[30, 10]	)
             self.assertEqual(list(x.items()	) ,				[("a", 30), ("b", 10)]	)
             self.assertEqual(list(__lowerCamelCase	) ,				["a", "b"]	)

             lowerCamelCase__		:    Any   =  ModelOutputTest(a=30 ,				c=10	)
             self.assertEqual(list(x.keys()	) ,				["a", "c"]	)
             self.assertEqual(list(x.values()	) ,				[30, 10]	)
             self.assertEqual(list(x.items()	) ,				[("a", 30), ("c", 10)]	)
             self.assertEqual(list(__lowerCamelCase	) ,				["a", "c"]	)

             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    Optional[int]   =  x.update({"d": 20}	)
             with self.assertRaises(__lowerCamelCase	):
                   del x["a"]
             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    List[Any]   =  x.pop("a"	)
             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    List[str]   =  x.setdefault("d" ,				32	)





       def 						lowerCAmelCase					(       self							:      Any	):


             '''simple docstring'''



             lowerCamelCase__		:    List[Any]   =  ModelOutputTest(a=30	)
             lowerCamelCase__		:    Tuple   =  10
             self.assertEqual(x.a ,				10	)
             self.assertEqual(x["a"] ,				10	)





       def 						lowerCAmelCase					(       self							:      Optional[int]	):


             '''simple docstring'''



             lowerCamelCase__		:    List[Any]   =  ModelOutputTest(a=30	)
             lowerCamelCase__		:    Optional[int]   =  10
             self.assertEqual(x.a ,				10	)
             self.assertEqual(x["a"] ,				10	)





       def 						lowerCAmelCase					(       self							:      Dict	):


             '''simple docstring'''



             lowerCamelCase__		:    Dict   =  ModelOutputTest({"a": 30, "b": 10}	)
             self.assertEqual(list(x.keys()	) ,				["a", "b"]	)
             self.assertEqual(x.a ,				30	)
             self.assertEqual(x.b ,				10	)





       def 						lowerCAmelCase					(       self							:      Any	):


             '''simple docstring'''



             lowerCamelCase__		:    Union[str, Any]   =  ModelOutputTest([("a", 30), ("b", 10)]	)
             self.assertEqual(list(x.keys()	) ,				["a", "b"]	)
             self.assertEqual(x.a ,				30	)
             self.assertEqual(x.b ,				10	)

             with self.assertRaises(__lowerCamelCase	):
                   lowerCamelCase__		:    List[Any]   =  ModelOutputTest([("a", 30), (10, 10)]	)

             lowerCamelCase__		:    Dict   =  ModelOutputTest(a=(30, 30)	)
             self.assertEqual(list(x.keys()	) ,				["a"]	)
             self.assertEqual(x.a ,				(30, 30)	)






import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class       _lowercase			(							lowercase__):


       """simple docstring"""




       A__ 						=      "AutoFeatureExtractor"
       A__ 						=      "Speech2Text2Tokenizer"





       def __init__(       self							:      List[str] ,				__lowerCamelCase							:      Dict ,				__lowerCamelCase							:      str	):


             '''simple docstring'''



             super().__init__(__lowerCamelCase ,				__lowerCamelCase	)
             lowerCamelCase__		:    Optional[Any]   =  self.feature_extractor
             lowerCamelCase__		:    Optional[int]   =  False





       def __call__(       self							:      List[str] ,				*__lowerCamelCase							:      Union[str, Any] ,				**__lowerCamelCase							:      List[Any]	):


             '''simple docstring'''



             if self._in_target_context_manager:
                   return self.current_processor(*__lowerCamelCase ,				**__lowerCamelCase	)

             if "raw_speech" in kwargs:
                   warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."	)
                   lowerCamelCase__		:    List[Any]   =  kwargs.pop("raw_speech"	)
             else:
                   lowerCamelCase__		:    str   =  kwargs.pop("audio" ,				__lowerCamelCase	)
             lowerCamelCase__		:    Optional[Any]   =  kwargs.pop("sampling_rate" ,				__lowerCamelCase	)
             lowerCamelCase__		:    Union[str, Any]   =  kwargs.pop("text" ,				__lowerCamelCase	)
             if len(__lowerCamelCase	) > 0:
                   lowerCamelCase__		:    Dict   =  args[0]
                   lowerCamelCase__		:    int   =  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:
                   lowerCamelCase__		:    str   =  self.feature_extractor(__lowerCamelCase ,				*__lowerCamelCase ,				sampling_rate=__lowerCamelCase ,				**__lowerCamelCase	)
             if text is not None:
                   lowerCamelCase__		:    Optional[int]   =  self.tokenizer(__lowerCamelCase ,				**__lowerCamelCase	)

             if text is None:
                   return inputs
             elif audio is None:
                   return encodings
             else:
                   lowerCamelCase__		:    Optional[int]   =  encodings["input_ids"]
                   return inputs





       def 						lowerCAmelCase					(       self							:      Any ,				*__lowerCamelCase							:      Any ,				**__lowerCamelCase							:      Any	):


             '''simple docstring'''



             return self.tokenizer.batch_decode(*__lowerCamelCase ,				**__lowerCamelCase	)





       def 						lowerCAmelCase					(       self							:      Dict ,				*__lowerCamelCase							:      int ,				**__lowerCamelCase							:      List[str]	):


             '''simple docstring'''



             return self.tokenizer.decode(*__lowerCamelCase ,				**__lowerCamelCase	)





       @contextmanager
       def 						lowerCAmelCase					(       self							:      Any	):


             '''simple docstring'''



             warnings.warn(
                 "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
                 "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
                 "your audio inputs, or in a separate call."	)
             lowerCamelCase__		:    int   =  True
             lowerCamelCase__		:    List[Any]   =  self.tokenizer
             yield
             lowerCamelCase__		:    Optional[int]   =  self.feature_extractor
             lowerCamelCase__		:    List[str]   =  False


