






'''simple docstring'''







import gc
import unittest

import numpy as np
import torch

from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps

from ..pipeline_params import UNCONDITIONAL_AUDIO_GENERATION_BATCH_PARAMS, UNCONDITIONAL_AUDIO_GENERATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()

class _lowercase			(       a__       ,   unittest.TestCase	):

							'''simple docstring'''





							a          = DanceDiffusionPipeline
							a          = UNCONDITIONAL_AUDIO_GENERATION_PARAMS
							a          = PipelineTesterMixin.required_optional_params - {
							    """callback""",
							    """latents""",
							    """callback_steps""",
							    """output_type""",
							    """num_images_per_prompt""",
							}
							a          = UNCONDITIONAL_AUDIO_GENERATION_BATCH_PARAMS
							a          = False
							a          = False




							def 	lowerCamelCase_       (							self:       List[str]  ):
														torch.manual_seed(0  )
														lowerCamelCase__      :			List[Any] 						= UNetaDModel(
														    block_out_channels=(32, 32, 64)    ,							extra_in_channels=16    ,							sample_size=512    ,							sample_rate=16_000    ,							in_channels=2    ,							out_channels=2    ,							flip_sin_to_cos=_A    ,							use_timestep_embedding=_A    ,							time_embedding_type="""fourier"""    ,							mid_block_type="""UNetMidBlock1D"""    ,							down_block_types=("""DownBlock1DNoSkip""", """DownBlock1D""", """AttnDownBlock1D""")    ,							up_block_types=("""AttnUpBlock1D""", """UpBlock1D""", """UpBlock1DNoSkip""")    ,							)
														lowerCamelCase__      :			int 						= IPNDMScheduler()

														lowerCamelCase__      :			Union[str, Any] 						= {
														    'unet': unet,
														    'scheduler': scheduler,
														}
														return components




							def 	lowerCamelCase_       (							self:       Dict    ,							UpperCamelCase__:       str    ,							UpperCamelCase__:       Optional[int]=0  ):

														if str(_A  ).startswith("""mps"""  ):
																					lowerCamelCase__      :			str 						= torch.manual_seed(_A  )
														else:
																					lowerCamelCase__      :			Optional[Any] 						= torch.Generator(device=_A  ).manual_seed(_A  )
														lowerCamelCase__      :			int 						= {
														    'batch_size': 1,
														    'generator': generator,
														    'num_inference_steps': 4,
														}
														return inputs




							def 	lowerCamelCase_       (							self:       List[Any]  ):
														lowerCamelCase__      :			List[str] 						= 'cpu'  # ensure determinism for the device-dependent torch.Generator
														lowerCamelCase__      :			int 						= self.get_dummy_components()
														lowerCamelCase__      :			Optional[Any] 						= DanceDiffusionPipeline(**_A  )
														lowerCamelCase__      :			int 						= pipe.to(_A  )
														pipe.set_progress_bar_config(disable=_A  )

														lowerCamelCase__      :			Union[str, Any] 						= self.get_dummy_inputs(_A  )
														lowerCamelCase__      :			List[str] 						= pipe(**_A  )
														lowerCamelCase__      :			List[Any] 						= output.audios

														lowerCamelCase__      :			List[str] 						= audio[0, -3:, -3:]

														assert audio.shape == (1, 2, components["unet"].sample_size)
														lowerCamelCase__      :			Optional[Any] 						= np.array([-0.7_265, 1.0_000, -0.8_388, 0.1_175, 0.9_498, -1.0_000]  )
														assert np.abs(audio_slice.flatten() - expected_slice  ).max() < 1e-2




							@skip_mps
							def 	lowerCamelCase_       (							self:       Any  ):
														return super().test_save_load_local()




							@skip_mps
							def 	lowerCamelCase_       (							self:       Optional[int]  ):
														return super().test_dict_tuple_outputs_equivalent(expected_max_difference=3e-3  )




							@skip_mps
							def 	lowerCamelCase_       (							self:       Optional[Any]  ):
														return super().test_save_load_optional_components()




							@skip_mps
							def 	lowerCamelCase_       (							self:       Any  ):
														return super().test_attention_slicing_forward_pass()




							def 	lowerCamelCase_       (							self:       str  ):
														super().test_inference_batch_single_identical(expected_max_diff=3e-3  )



@slow
@require_torch_gpu
class _lowercase			(       unittest.TestCase	):

							'''simple docstring'''





							def 	lowerCamelCase_       (							self:       List[str]  ):
														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()




							def 	lowerCamelCase_       (							self:       str  ):
														lowerCamelCase__      :			List[Any] 						= torch_device

														lowerCamelCase__      :			int 						= DanceDiffusionPipeline.from_pretrained("""harmonai/maestro-150k"""  )
														lowerCamelCase__      :			int 						= pipe.to(_A  )
														pipe.set_progress_bar_config(disable=_A  )

														lowerCamelCase__      :			Optional[int] 						= torch.manual_seed(0  )
														lowerCamelCase__      :			str 						= pipe(generator=_A    ,							num_inference_steps=100    ,							audio_length_in_s=4.096  )
														lowerCamelCase__      :			str 						= output.audios

														lowerCamelCase__      :			List[str] 						= audio[0, -3:, -3:]

														assert audio.shape == (1, 2, pipe.unet.sample_size)
														lowerCamelCase__      :			Union[str, Any] 						= np.array([-0.0_192, -0.0_231, -0.0_318, -0.0_059, 0.0_002, -0.0_020]  )

														assert np.abs(audio_slice.flatten() - expected_slice  ).max() < 1e-2




							def 	lowerCamelCase_       (							self:       str  ):
														lowerCamelCase__      :			str 						= torch_device

														lowerCamelCase__      :			Tuple 						= DanceDiffusionPipeline.from_pretrained("""harmonai/maestro-150k"""    ,							torch_dtype=torch.floataa  )
														lowerCamelCase__      :			Optional[int] 						= pipe.to(_A  )
														pipe.set_progress_bar_config(disable=_A  )

														lowerCamelCase__      :			Union[str, Any] 						= torch.manual_seed(0  )
														lowerCamelCase__      :			Optional[int] 						= pipe(generator=_A    ,							num_inference_steps=100    ,							audio_length_in_s=4.096  )
														lowerCamelCase__      :			Union[str, Any] 						= output.audios

														lowerCamelCase__      :			int 						= audio[0, -3:, -3:]

														assert audio.shape == (1, 2, pipe.unet.sample_size)
														lowerCamelCase__      :			List[str] 						= np.array([-0.0_367, -0.0_488, -0.0_771, -0.0_525, -0.0_444, -0.0_341]  )

														assert np.abs(audio_slice.flatten() - expected_slice  ).max() < 1e-2









'''simple docstring'''







import sys
import turtle





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase   )   -> tuple[float, float]:
							return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase       ,    )   -> None:
							my_pen.up()
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )
							my_pen.down()
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )

							if depth == 0:
														return

							triangle(UpperCamelCase       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    depth - 1   )
							triangle(UpperCamelCase       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    depth - 1   )
							triangle(UpperCamelCase       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    depth - 1   )


if __name__ == "__main__":
			if len(sys.argv) != 2:
						raise ValueError(
						    '''Correct format for using this script: '''
						    '''python fractals.py <int:depth_for_fractal>'''
						)
			_A			:    Any					  =turtle.Turtle()
			my_pen.ht()
			my_pen.speed(5)
			my_pen.pencolor('''red''')

			_A			:    Dict					  =[(-175, -125), (0, 175), (175, -125)]  # vertices of triangle
			triangle(vertices[0], vertices[1], vertices[2], int(sys.argv[1]))

