





import logging
import os
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

from tqdm import auto as tqdm_lib


__lowerCamelCase       :     Any   =     {
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

__lowerCamelCase       :     int   =     logging.WARNING



def 		A_				(     )						-> Optional[int]:
 UpperCamelCase	:					int       	=   os.getenv("DATASETS_VERBOSITY"							,   _lowerCAmelCase     )
 if env_level_str:
  if env_level_str in log_levels:
   return log_levels[env_level_str]
  else:
   logging.getLogger().warning(
       F"""Unknown option DATASETS_VERBOSITY={env_level_str}, """
       F"""has to be one of: { ", ".join(log_levels.keys()     ) }"""     )
 return _default_log_level



def 		A_				(     )						-> str:
 return __name__.split("."     )[0]



def 		A_				(     )						-> logging.Logger:
 return logging.getLogger(_get_library_name()     )



def 		A_				(     )						-> None:
 # Apply our default configuration to the library root logger.
 UpperCamelCase	:					Optional[int]       	=   _get_library_root_logger()
 library_root_logger.setLevel(_get_default_logging_level()     )



def 		A_				(     )						-> None:
 UpperCamelCase	:					Optional[int]       	=   _get_library_root_logger()
 library_root_logger.setLevel(logging.NOTSET     )



def 		A_				(     _lowerCAmelCase = None     )						-> logging.Logger:
 if name is None:
  UpperCamelCase	:					Union[str, Any]       	=   _get_library_name()
 return logging.getLogger(_lowerCAmelCase     )



def 		A_				(     )						-> int:
 return _get_library_root_logger().getEffectiveLevel()



def 		A_				(     _lowerCAmelCase     )						-> None:
 _get_library_root_logger().setLevel(_lowerCAmelCase     )



def 		A_				(     )						-> List[str]:
 return set_verbosity(_lowerCAmelCase     )



def 		A_				(     )						-> Dict:
 return set_verbosity(_lowerCAmelCase     )



def 		A_				(     )						-> Union[str, Any]:
 return set_verbosity(_lowerCAmelCase     )



def 		A_				(     )						-> List[Any]:
 return set_verbosity(_lowerCAmelCase     )



def 		A_				(     )						-> None:
 UpperCamelCase	:					Any       	=   False



def 		A_				(     )						-> None:
 UpperCamelCase	:					int       	=   True


# Configure the library root logger at the module level (singleton-like)
_configure_library_root_logger()



class 					A__   :





      def __init__( self       ,							*A_       ,							**A_   ):  # pylint: disable=unused-argument
       '''simple docstring'''




       UpperCamelCase	:					List[Any]       	=   args[0] if args else None





      def __iter__( self   ):
       '''simple docstring'''




       return iter(self._iterator   )





      def __getattr__( self       ,							A_   ):
       '''simple docstring'''




       def empty_fn(*A_       ,							**A_   ):  # pylint: disable=unused-argument
        return

       return empty_fn





      def __enter__( self   ):
       '''simple docstring'''




       return self





      def __exit__( self       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       return


__lowerCamelCase       :     List[str]   =     True



class 					A__   :





      def __call__( self       ,							*A_       ,							A_=False       ,							**A_   ):
       '''simple docstring'''




       if _tqdm_active and not disable:
        return tqdm_lib.tqdm(*A_       ,							**A_   )
       else:
        return EmptyTqdm(*A_       ,							**A_   )





      def        __UpperCamelCase( self       ,							*A_       ,							**A_   ):
       '''simple docstring'''




       UpperCamelCase	:					int       	=   None
       if _tqdm_active:
        return tqdm_lib.tqdm.set_lock(*A_       ,							**A_   )





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       if _tqdm_active:
        return tqdm_lib.tqdm.get_lock()


__lowerCamelCase       :     int   =     _tqdm_cls()



def 		A_				(     )						-> bool:
 global _tqdm_active
 return bool(_tqdm_active     )



def 		A_				(     )						-> Any:
 global _tqdm_active
 UpperCamelCase	:					int       	=   True



def 		A_				(     )						-> Tuple:
 global _tqdm_active
 UpperCamelCase	:					Dict       	=   False

'''simple docstring'''




import unittest

from transformers import load_tool
from transformers.utils import is_torch_available


if is_torch_available():
						import torch

from transformers.testing_utils import require_torch

from .test_tools_common import ToolTesterMixin





@require_torch
class     __magic_name__						(    unittest.TestCase,     _UpperCAmelCase):







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Optional[Any]    ):
										lowercase_					:			List[str]										=       load_tool("""text-to-speech"""    )
										self.tool.setup()







			def 	SCREAMING_SNAKE_CASE_     (	self				:  List[Any]    ):
										# SpeechT5 isn't deterministic
										torch.manual_seed(0    )
										lowercase_					:			List[str]										=       self.tool("""hey"""    )
										lowercase_					:			Optional[int]										=       result.to_raw()
										self.assertTrue(
										    torch.allclose(
										        resulting_tensor[:3]				,			torch.tensor([-0.0_00_59_66_66_88_32_11_58_29, -0.0_00_36_57_64_01_90_79_50_64, -0.00_01_34_39_50_27_99_88_34_85]    )				,			)    )







			def 	SCREAMING_SNAKE_CASE_     (	self				:  List[Any]    ):
										# SpeechT5 isn't deterministic
										torch.manual_seed(0    )
										lowercase_					:			Union[str, Any]										=       self.tool("""hey"""    )
										lowercase_					:			int										=       result.to_raw()
										self.assertTrue(
										    torch.allclose(
										        resulting_tensor[:3]				,			torch.tensor([-0.0_00_59_66_66_88_32_11_58_29, -0.0_00_36_57_64_01_90_79_50_64, -0.00_01_34_39_50_27_99_88_34_85]    )				,			)    )





