






import os
import tempfile
import unittest
import uuid
from pathlib import Path

from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision
from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText
from transformers.utils import is_soundfile_availble, is_torch_available, is_vision_available


if is_torch_available():
	import torch

if is_soundfile_availble():
	import soundfile as sf

if is_vision_available():
	from PIL import Image
def 					snake_case_						(   lowerCAmelCase_				:  int=""					):
							__lowercase					:							str			=   tempfile.mkdtemp()
							return os.path.join(lowerCAmelCase_				,				str(uuid.uuida()					) + suffix					)

@require_soundfile
@require_torch
class 						lowerCAmelCase   (       unittest.TestCase	):

					'''simple docstring'''

					def 					lowerCAmelCase (     self :		Dict							)	->     Dict:


												"""simple docstring"""

												__lowercase					:							Optional[int]			=   torch.rand(12						,   dtype=torch.floataa							) - 0.5
												__lowercase					:							Dict			=   AgentAudio(__a							)
												__lowercase					:							List[str]			=   str(agent_type.to_string()							)

												# Ensure that the tensor and the agent_type's tensor are the same
												self.assertTrue(torch.allclose(__a						,   agent_type.to_raw()						,   atol=1E-4							)							)

												del agent_type

												# Ensure the path remains even after the object deletion
												self.assertTrue(os.path.exists(__a							)							)

												# Ensure that the file contains the same value as the original tensor
												__lowercase	,	__lowercase					:							List[str]			=   sf.read(__a							)
												self.assertTrue(torch.allclose(__a						,   torch.tensor(__a							)						,   atol=1E-4							)							)



					def 					lowerCAmelCase (     self :		List[str]							)	->     Tuple:


												"""simple docstring"""

												__lowercase					:							List[str]			=   torch.rand(12						,   dtype=torch.floataa							) - 0.5
												__lowercase					:							List[str]			=   get_new_path(suffix=""".wav"""							)
												sf.write(__a						,   __a						,   16000							)

												__lowercase					:							Optional[int]			=   AgentAudio(__a							)

												self.assertTrue(torch.allclose(__a						,   agent_type.to_raw()						,   atol=1E-4							)							)
												self.assertEqual(agent_type.to_string()						,   __a							)







@require_vision
@require_torch
class 						lowerCAmelCase   (       unittest.TestCase	):

					'''simple docstring'''

					def 					lowerCAmelCase (     self :		Union[str, Any]							)	->     Any:


												"""simple docstring"""

												__lowercase					:							Optional[Any]			=   torch.randint(0						,   256						,   (64, 64, 3)							)
												__lowercase					:							str			=   AgentImage(__a							)
												__lowercase					:							int			=   str(agent_type.to_string()							)

												# Ensure that the tensor and the agent_type's tensor are the same
												self.assertTrue(torch.allclose(__a						,   agent_type._tensor						,   atol=1E-4							)							)

												self.assertIsInstance(agent_type.to_raw()						,   Image.Image							)

												# Ensure the path remains even after the object deletion
												del agent_type
												self.assertTrue(os.path.exists(__a							)							)



					def 					lowerCAmelCase (     self :		Union[str, Any]							)	->     List[str]:


												"""simple docstring"""

												__lowercase					:							Optional[int]			=   Path(get_tests_dir("""fixtures/tests_samples/COCO"""							)							) / """000000039769.png"""
												__lowercase					:							Union[str, Any]			=   Image.open(__a							)
												__lowercase					:							List[str]			=   AgentImage(__a							)

												self.assertTrue(path.samefile(agent_type.to_string()							)							)
												self.assertTrue(image == agent_type.to_raw()							)

												# Ensure the path remains even after the object deletion
												del agent_type
												self.assertTrue(os.path.exists(__a							)							)



					def 					lowerCAmelCase (     self :		Optional[int]							)	->     Optional[int]:


												"""simple docstring"""

												__lowercase					:							int			=   Path(get_tests_dir("""fixtures/tests_samples/COCO"""							)							) / """000000039769.png"""
												__lowercase					:							List[Any]			=   Image.open(__a							)
												__lowercase					:							Tuple			=   AgentImage(__a							)

												self.assertFalse(path.samefile(agent_type.to_string()							)							)
												self.assertTrue(image == agent_type.to_raw()							)

												# Ensure the path remains even after the object deletion
												del agent_type
												self.assertTrue(os.path.exists(__a							)							)







class 						lowerCAmelCase   (       unittest.TestCase	):

					'''simple docstring'''

					def 					lowerCAmelCase (     self :		Optional[Any]							)	->     List[str]:


												"""simple docstring"""

												__lowercase					:							Any			=   """Hey!"""
												__lowercase					:							Dict			=   AgentText(__a							)

												self.assertEqual(__a						,   agent_type.to_string()							)
												self.assertEqual(__a						,   agent_type.to_raw()							)
												self.assertEqual(__a						,   __a							)







def 					snake_case_						(   lowerCAmelCase_				:  list					):

							if len(lowerCAmelCase_					) <= 1:
														return [tuple(lowerCAmelCase_					)]

							__lowercase					:							Any			=   []

							def generate(lowerCAmelCase_				:  int				,				lowerCAmelCase_				:  list					):
														if k == 1:
																					res.append(tuple(arr[:]					)					)
																					return

														generate(k - 1				,				lowerCAmelCase_					)

														for i in range(k - 1					):
																					if k % 2 == 0:  # k is even
																												__lowercase	,	__lowercase					:							List[str]			=   arr[k - 1], arr[i]
																					else:  # k is odd
																												__lowercase	,	__lowercase					:							Any			=   arr[k - 1], arr[0]
																					generate(k - 1				,				lowerCAmelCase_					)

							generate(len(lowerCAmelCase_					)				,				lowerCAmelCase_					)
							return res


if __name__ == "__main__":
	lowerCamelCase       :       Union[str, Any]        =				input('''Enter numbers separated by a comma:\n''').strip()
	lowerCamelCase       :       Optional[Any]        =				[int(item) for item in user_input.split(''',''')]
	print(heaps(arr))