






"""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    __UpperCAmelCase(       unittest.TestCase  ,  SCREAMING_SNAKE_CASE__							):




						"""simple docstring"""




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Dict=	load_tool("text-to-speech"      )
												self.tool.setup()




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												# SpeechT5 isn't deterministic
												torch.manual_seed(0      )
												lowercase__    :				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]      )	,  )      )




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												# SpeechT5 isn't deterministic
												torch.manual_seed(0      )
												lowercase__    :				Dict=	self.tool("hey"      )
												lowercase__    :				Any=	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]      )	,  )      )














"""simple docstring"""







import os
from pathlib import Path





def 						lowercase__()    ->List[Any]:




						"""simple docstring"""



						from torch.utils.cpp_extension import load

						lowercase__    :				Any=	Path(A						).resolve().parent.parent.parent / "kernels" / "deformable_detr"
						lowercase__    :				Any=	[
						    root / filename
						    for filename in [
						        "vision.cpp",
						        os.path.join("cpu" ,		"ms_deform_attn_cpu.cpp"						),
						        os.path.join("cuda" ,		"ms_deform_attn_cuda.cu"						),
						    ]
						]

						load(
						    "MultiScaleDeformableAttention" ,		A ,		with_cuda=A ,		extra_include_paths=[str(A						)] ,		extra_cflags=["-DWITH_CUDA=1"] ,		extra_cuda_cflags=[
						        "-DCUDA_HAS_FP16=1",
						        "-D__CUDA_NO_HALF_OPERATORS__",
						        "-D__CUDA_NO_HALF_CONVERSIONS__",
						        "-D__CUDA_NO_HALF2_OPERATORS__",
						    ] ,		)

						import MultiScaleDeformableAttention as MSDA

						return MSDA






