




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 						__lowercase		(unittest.TestCase					,		UpperCamelCase__							):




      """simple docstring"""





      def      UpperCAmelCase				(				self     )		->    int:
         snake_case				:    List[Any]           =	load_tool("""text-to-speech"""     )
         self.tool.setup()

      def      UpperCAmelCase				(				self     )		->    Tuple:
         # SpeechT5 isn't deterministic
         torch.manual_seed(0     )
         snake_case				:    List[Any]           =	self.tool("""hey"""     )
         snake_case				:    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      UpperCAmelCase				(				self     )		->    Optional[Any]:
         # SpeechT5 isn't deterministic
         torch.manual_seed(0     )
         snake_case				:    Union[str, Any]           =	self.tool("""hey"""     )
         snake_case				:    Tuple           =	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]     )    ,				)     )











import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline




@pytest.mark.integration
def 						SCREAMING_SNAKE_CASE__ (   )  ->       List[Any]:
   with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT					):
      with pytest.raises(lowercase					):
         requests.request("""GET"""						,"""https://huggingface.co"""					)
      with pytest.raises(requests.exceptions.ConnectTimeout					):
         requests.request("""GET"""						,"""https://huggingface.co"""						,timeout=1.0					)




@pytest.mark.integration
def 						SCREAMING_SNAKE_CASE__ (   )  ->       Any:
   with offline(OfflineSimulationMode.CONNECTION_FAILS					):
      with pytest.raises(requests.exceptions.ConnectionError					):
         requests.request("""GET"""						,"""https://huggingface.co"""					)




def 						SCREAMING_SNAKE_CASE__ (   )  ->       int:
   with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1					):
      with pytest.raises(lowercase					):
         http_head("""https://huggingface.co"""					)





