


import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPanoramaPipeline,
    UNetaDConditionModel,
)
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 TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()



@skip_mps
class  lowerCAmelCase				(				__lowercase      ,				__lowercase      ,				unittest.TestCase							):
	_lowerCamelCase   :					List[Any]			      = StableDiffusionPanoramaPipeline
	_lowerCamelCase   :					List[str]			      = TEXT_TO_IMAGE_PARAMS
	_lowerCamelCase   :					int			      = TEXT_TO_IMAGE_BATCH_PARAMS
	_lowerCamelCase   :					Union[str, Any]			      = TEXT_TO_IMAGE_IMAGE_PARAMS
	_lowerCamelCase   :					Any			      = TEXT_TO_IMAGE_IMAGE_PARAMS



	def 				lowercase     (					self    ):
		torch.manual_seed(0    )
		lowerCAmelCase					:    Any      							= UNetaDConditionModel(
		    block_out_channels=(32, 64) ,					layers_per_block=1 ,					sample_size=32 ,					in_channels=4 ,					out_channels=4 ,					down_block_types=('DownBlock2D', 'CrossAttnDownBlock2D') ,					up_block_types=('CrossAttnUpBlock2D', 'UpBlock2D') ,					cross_attention_dim=32 ,					)
		lowerCAmelCase					:    List[str]      							= DDIMScheduler()
		torch.manual_seed(0    )
		lowerCAmelCase					:    str      							= AutoencoderKL(
		    block_out_channels=[32, 64] ,					in_channels=3 ,					out_channels=3 ,					down_block_types=['DownEncoderBlock2D', 'DownEncoderBlock2D'] ,					up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D'] ,					latent_channels=4 ,					)
		torch.manual_seed(0    )
		lowerCAmelCase					:    Optional[Any]      							= CLIPTextConfig(
		    bos_token_id=0 ,					eos_token_id=2 ,					hidden_size=32 ,					intermediate_size=37 ,					layer_norm_eps=1e-0_5 ,					num_attention_heads=4 ,					num_hidden_layers=5 ,					pad_token_id=1 ,					vocab_size=1000 ,					)
		lowerCAmelCase					:    List[Any]      							= CLIPTextModel(_A    )
		lowerCAmelCase					:    Tuple      							= CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'    )

		lowerCAmelCase					:    List[Any]      							= {
		    'unet': unet,
		    'scheduler': scheduler,
		    'vae': vae,
		    'text_encoder': text_encoder,
		    'tokenizer': tokenizer,
		    'safety_checker': None,
		    'feature_extractor': None,
		}
		return components



	def 				lowercase     (					self ,					snake_case__ ,					snake_case__=0    ):
		lowerCAmelCase					:    List[str]      							= torch.manual_seed(_A    )
		lowerCAmelCase					:    Union[str, Any]      							= {
		    'prompt': 'a photo of the dolomites',
		    'generator': generator,
		    # Setting height and width to None to prevent OOMs on CPU.
		    'height': None,
		    'width': None,
		    'num_inference_steps': 1,
		    'guidance_scale': 6.0,
		    'output_type': 'numpy',
		}
		return inputs



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Tuple      							= 'cpu'  # ensure determinism for the device-dependent torch.Generator
		lowerCAmelCase					:    List[str]      							= self.get_dummy_components()
		lowerCAmelCase					:    int      							= StableDiffusionPanoramaPipeline(**_A    )
		lowerCAmelCase					:    Dict      							= sd_pipe.to(_A    )
		sd_pipe.set_progress_bar_config(disable=_A    )

		lowerCAmelCase					:    int      							= self.get_dummy_inputs(_A    )
		lowerCAmelCase					:    List[Any]      							= sd_pipe(**_A    ).images
		lowerCAmelCase					:    Dict      							= image[0, -3:, -3:, -1]
		assert image.shape == (1, 64, 64, 3)

		lowerCAmelCase					:    Optional[Any]      							= np.array([0.6_1_8_6, 0.5_3_7_4, 0.4_9_1_5, 0.4_1_3_5, 0.4_1_1_4, 0.4_5_6_3, 0.5_1_2_8, 0.4_9_7_7, 0.4_7_5_7]    )

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



	def 				lowercase     (					self    ):
		super().test_inference_batch_consistent(batch_sizes=[1, 2]    )



	def 				lowercase     (					self    ):
		super().test_inference_batch_single_identical(batch_size=2 ,					expected_max_diff=3.2_5e-3    )



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Tuple      							= 'cpu'  # ensure determinism for the device-dependent torch.Generator
		lowerCAmelCase					:    Union[str, Any]      							= self.get_dummy_components()
		lowerCAmelCase					:    int      							= StableDiffusionPanoramaPipeline(**_A    )
		lowerCAmelCase					:    Any      							= sd_pipe.to(_A    )
		sd_pipe.set_progress_bar_config(disable=_A    )

		lowerCAmelCase					:    str      							= self.get_dummy_inputs(_A    )
		lowerCAmelCase					:    Dict      							= 'french fries'
		lowerCAmelCase					:    Optional[int]      							= sd_pipe(**_A ,					negative_prompt=_A    )
		lowerCAmelCase					:    Tuple      							= output.images
		lowerCAmelCase					:    List[Any]      							= image[0, -3:, -3:, -1]

		assert image.shape == (1, 64, 64, 3)

		lowerCAmelCase					:    Dict      							= np.array([0.6_1_8_7, 0.5_3_7_5, 0.4_9_1_5, 0.4_1_3_6, 0.4_1_1_4, 0.4_5_6_3, 0.5_1_2_8, 0.4_9_7_6, 0.4_7_5_7]    )

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



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    List[str]      							= 'cpu'  # ensure determinism for the device-dependent torch.Generator
		lowerCAmelCase					:    Dict      							= self.get_dummy_components()
		lowerCAmelCase					:    int      							= StableDiffusionPanoramaPipeline(**_A    )
		lowerCAmelCase					:    List[str]      							= sd_pipe.to(_A    )
		sd_pipe.set_progress_bar_config(disable=_A    )

		lowerCAmelCase					:    Tuple      							= self.get_dummy_inputs(_A    )
		lowerCAmelCase					:    Any      							= sd_pipe(**_A ,					view_batch_size=2    )
		lowerCAmelCase					:    List[Any]      							= output.images
		lowerCAmelCase					:    Optional[Any]      							= image[0, -3:, -3:, -1]

		assert image.shape == (1, 64, 64, 3)

		lowerCAmelCase					:    str      							= np.array([0.6_1_8_7, 0.5_3_7_5, 0.4_9_1_5, 0.4_1_3_6, 0.4_1_1_4, 0.4_5_6_3, 0.5_1_2_8, 0.4_9_7_6, 0.4_7_5_7]    )

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



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    List[str]      							= 'cpu'  # ensure determinism for the device-dependent torch.Generator
		lowerCAmelCase					:    Any      							= self.get_dummy_components()
		lowerCAmelCase					:    str      							= EulerAncestralDiscreteScheduler(
		    beta_start=0.0_0_0_8_5 ,					beta_end=0.0_1_2 ,					beta_schedule='scaled_linear'    )
		lowerCAmelCase					:    Optional[Any]      							= StableDiffusionPanoramaPipeline(**_A    )
		lowerCAmelCase					:    Optional[Any]      							= sd_pipe.to(_A    )
		sd_pipe.set_progress_bar_config(disable=_A    )

		lowerCAmelCase					:    List[str]      							= self.get_dummy_inputs(_A    )
		lowerCAmelCase					:    Optional[Any]      							= sd_pipe(**_A    ).images
		lowerCAmelCase					:    List[Any]      							= image[0, -3:, -3:, -1]

		assert image.shape == (1, 64, 64, 3)

		lowerCAmelCase					:    List[str]      							= np.array([0.4_0_2_4, 0.6_5_1_0, 0.4_9_0_1, 0.5_3_7_8, 0.5_8_1_3, 0.5_6_2_2, 0.4_7_9_5, 0.4_4_6_7, 0.4_9_5_2]    )

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



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    str      							= 'cpu'  # ensure determinism for the device-dependent torch.Generator
		lowerCAmelCase					:    Any      							= self.get_dummy_components()
		lowerCAmelCase					:    Union[str, Any]      							= PNDMScheduler(
		    beta_start=0.0_0_0_8_5 ,					beta_end=0.0_1_2 ,					beta_schedule='scaled_linear' ,					skip_prk_steps=_A    )
		lowerCAmelCase					:    int      							= StableDiffusionPanoramaPipeline(**_A    )
		lowerCAmelCase					:    Union[str, Any]      							= sd_pipe.to(_A    )
		sd_pipe.set_progress_bar_config(disable=_A    )

		lowerCAmelCase					:    Any      							= self.get_dummy_inputs(_A    )
		lowerCAmelCase					:    Union[str, Any]      							= sd_pipe(**_A    ).images
		lowerCAmelCase					:    Dict      							= image[0, -3:, -3:, -1]

		assert image.shape == (1, 64, 64, 3)

		lowerCAmelCase					:    Dict      							= np.array([0.6_3_9_1, 0.6_2_9_1, 0.4_8_6_1, 0.5_1_3_4, 0.5_5_5_2, 0.4_5_7_8, 0.5_0_3_2, 0.5_0_2_3, 0.4_5_3_9]    )

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



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



	def 				lowercase     (					self    ):
		super().tearDown()
		gc.collect()
		torch.cuda.empty_cache()



	def 				lowercase     (					self ,					snake_case__=0    ):
		lowerCAmelCase					:    Optional[int]      							= torch.manual_seed(_A    )
		lowerCAmelCase					:    List[Any]      							= {
		    'prompt': 'a photo of the dolomites',
		    'generator': generator,
		    'num_inference_steps': 3,
		    'guidance_scale': 7.5,
		    'output_type': 'numpy',
		}
		return inputs



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Union[str, Any]      							= 'stabilityai/stable-diffusion-2-base'
		lowerCAmelCase					:    str      							= DDIMScheduler.from_pretrained(_A ,					subfolder='scheduler'    )
		lowerCAmelCase					:    List[Any]      							= StableDiffusionPanoramaPipeline.from_pretrained(_A ,					scheduler=_A ,					safety_checker=_A    )
		pipe.to(_A    )
		pipe.set_progress_bar_config(disable=_A    )
		pipe.enable_attention_slicing()

		lowerCAmelCase					:    List[str]      							= self.get_inputs()
		lowerCAmelCase					:    int      							= pipe(**_A    ).images
		lowerCAmelCase					:    Any      							= image[0, -3:, -3:, -1].flatten()

		assert image.shape == (1, 512, 2048, 3)

		lowerCAmelCase					:    List[Any]      							= np.array(
		    [
		        0.3_6_9_6_8_3_9_2,
		        0.2_7_0_2_5_3_7_2,
		        0.3_2_4_4_6_7_6_6,
		        0.2_8_3_7_9_3_8_7,
		        0.3_6_3_6_3_2_7_4,
		        0.3_0_7_3_3_3_4_7,
		        0.2_7_1_0_0_0_2_7,
		        0.2_7_0_5_4_1_2_5,
		        0.2_5_5_3_6_0_9_6,
		    ]    )

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



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    List[Any]      							= StableDiffusionPanoramaPipeline.from_pretrained(
		    'stabilityai/stable-diffusion-2-base' ,					safety_checker=_A    )
		lowerCAmelCase					:    List[str]      							= LMSDiscreteScheduler.from_config(pipe.scheduler.config    )
		pipe.to(_A    )
		pipe.set_progress_bar_config(disable=_A    )
		pipe.enable_attention_slicing()

		lowerCAmelCase					:    List[Any]      							= self.get_inputs()
		lowerCAmelCase					:    List[Any]      							= pipe(**_A    ).images
		lowerCAmelCase					:    Union[str, Any]      							= image[0, -3:, -3:, -1].flatten()

		assert image.shape == (1, 512, 2048, 3)

		lowerCAmelCase					:    int      							= np.array(
		    [
		        [
		            0.0,
		            0.0,
		            0.0,
		            0.0,
		            0.0,
		            0.0,
		            0.0,
		            0.0,
		            0.0,
		        ]
		    ]    )

		assert np.abs(expected_slice - image_slice    ).max() < 1e-3



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Tuple      							= 0

		def callback_fn(snake_case__ ,					snake_case__ ,					snake_case__    ) -> None:
			lowerCAmelCase					:    Union[str, Any]      							= True
			nonlocal number_of_steps
			number_of_steps += 1
			if step == 1:
				lowerCAmelCase					:    List[Any]      							= latents.detach().cpu().numpy()
				assert latents.shape == (1, 4, 64, 256)
				lowerCAmelCase					:    List[Any]      							= latents[0, -3:, -3:, -1]

				lowerCAmelCase					:    Optional[Any]      							= np.array(
				    [
				        0.1_8_6_8_1_8_6_9,
				        0.3_3_9_0_7_8_1_6,
				        0.5_3_6_1_2_7_6,
				        0.1_4_4_3_2_8_6_5,
				        -0.0_2_8_5_6_6_1_1,
				        -0.7_3_9_4_1_1_2_3,
				        0.2_3_3_9_7_9_8_7,
				        0.4_7_3_2_2_6_8_2,
				        -0.3_7_8_2_3_1_6_4,
				    ]    )
				assert np.abs(latents_slice.flatten() - expected_slice    ).max() < 5e-2
			elif step == 2:
				lowerCAmelCase					:    int      							= latents.detach().cpu().numpy()
				assert latents.shape == (1, 4, 64, 256)
				lowerCAmelCase					:    int      							= latents[0, -3:, -3:, -1]

				lowerCAmelCase					:    Union[str, Any]      							= np.array(
				    [
				        0.1_8_5_3_9_6_4_5,
				        0.3_3_9_8_7_2_4_8,
				        0.5_3_7_8_5_5_9,
				        0.1_4_4_3_7_1_4_2,
				        -0.0_2_4_5_5_2_6_1,
				        -0.7_3_3_8_3_1_7,
				        0.2_3_9_9_0_7_5_5,
				        0.4_7_3_5_6_2_7_2,
				        -0.3_7_8_6_5_0_5,
				    ]    )

				assert np.abs(latents_slice.flatten() - expected_slice    ).max() < 5e-2

		lowerCAmelCase					:    int      							= False

		lowerCAmelCase					:    List[Any]      							= 'stabilityai/stable-diffusion-2-base'
		lowerCAmelCase					:    Union[str, Any]      							= DDIMScheduler.from_pretrained(_A ,					subfolder='scheduler'    )
		lowerCAmelCase					:    Optional[int]      							= StableDiffusionPanoramaPipeline.from_pretrained(_A ,					scheduler=_A ,					safety_checker=_A    )
		lowerCAmelCase					:    int      							= pipe.to(_A    )
		pipe.set_progress_bar_config(disable=_A    )
		pipe.enable_attention_slicing()

		lowerCAmelCase					:    Optional[Any]      							= self.get_inputs()
		pipe(**_A ,					callback=_A ,					callback_steps=1    )
		assert callback_fn.has_been_called
		assert number_of_steps == 3



	def 				lowercase     (					self    ):
		torch.cuda.empty_cache()
		torch.cuda.reset_max_memory_allocated()
		torch.cuda.reset_peak_memory_stats()

		lowerCAmelCase					:    List[Any]      							= 'stabilityai/stable-diffusion-2-base'
		lowerCAmelCase					:    Optional[int]      							= DDIMScheduler.from_pretrained(_A ,					subfolder='scheduler'    )
		lowerCAmelCase					:    Tuple      							= StableDiffusionPanoramaPipeline.from_pretrained(_A ,					scheduler=_A ,					safety_checker=_A    )
		lowerCAmelCase					:    Tuple      							= pipe.to(_A    )
		pipe.set_progress_bar_config(disable=_A    )
		pipe.enable_attention_slicing(1    )
		pipe.enable_sequential_cpu_offload()

		lowerCAmelCase					:    List[str]      							= self.get_inputs()
		lowerCAmelCase					:    Any      							= pipe(**_A    )

		lowerCAmelCase					:    Union[str, Any]      							= torch.cuda.max_memory_allocated()
		# make sure that less than 5.2 GB is allocated
		assert mem_bytes < 5.5 * 10**9




'''simple docstring'''




from typing import Any



class  lowerCAmelCase				:



	def __init__(					self ,					snake_case__    ):
		lowerCAmelCase					:    Optional[int]      							= data
		lowerCAmelCase					:    Optional[Any]      							= None



	def __repr__(					self    ):
		return f"Node({self.data})"



class  lowerCAmelCase				:



	def __init__(					self    ):
		lowerCAmelCase					:    Dict      							= None



	def __iter__(					self    ):
		lowerCAmelCase					:    Optional[Any]      							= self.head
		while node:
			yield node.data
			lowerCAmelCase					:    Optional[int]      							= node.next



	def __len__(					self    ):
		return sum(1 for _ in self    )



	def __repr__(					self    ):
		return "->".join([str(snake_case__    ) for item in self]    )



	def __getitem__(					self ,					snake_case__    ):
		if not 0 <= index < len(self    ):
			raise ValueError('list index out of range.'    )
		for i, node in enumerate(self    ):
			if i == index:
				return node
		return None



	def __setitem__(					self ,					snake_case__ ,					snake_case__    ):
		if not 0 <= index < len(self    ):
			raise ValueError('list index out of range.'    )
		lowerCAmelCase					:    Any      							= self.head
		for _ in range(snake_case__    ):
			lowerCAmelCase					:    List[str]      							= current.next
		lowerCAmelCase					:    int      							= data



	def 				lowercase     (					self ,					snake_case__    ):
		self.insert_nth(len(self    ) ,					snake_case__    )



	def 				lowercase     (					self ,					snake_case__    ):
		self.insert_nth(0 ,					snake_case__    )



	def 				lowercase     (					self ,					snake_case__ ,					snake_case__    ):
		if not 0 <= index <= len(self    ):
			raise IndexError('list index out of range'    )
		lowerCAmelCase					:    List[str]      							= Node(snake_case__    )
		if self.head is None:
			lowerCAmelCase					:    int      							= new_node
		elif index == 0:
			lowerCAmelCase					:    List[Any]      							= self.head  # link new_node to head
			lowerCAmelCase					:    List[Any]      							= new_node
		else:
			lowerCAmelCase					:    List[Any]      							= self.head
			for _ in range(index - 1    ):
				lowerCAmelCase					:    Union[str, Any]      							= temp.next
			lowerCAmelCase					:    Any      							= temp.next
			lowerCAmelCase					:    str      							= new_node



	def 				lowercase     (					self    ):  # print every node data
		print(self    )



	def 				lowercase     (					self    ):
		return self.delete_nth(0    )



	def 				lowercase     (					self    ):  # delete from tail
		return self.delete_nth(len(self    ) - 1    )



	def 				lowercase     (					self ,					snake_case__ = 0    ):
		if not 0 <= index <= len(self    ) - 1:  # test if index is valid
			raise IndexError('List index out of range.'    )
		lowerCAmelCase					:    List[str]      							= self.head  # default first node
		if index == 0:
			lowerCAmelCase					:    Tuple      							= self.head.next
		else:
			lowerCAmelCase					:    Dict      							= self.head
			for _ in range(index - 1    ):
				lowerCAmelCase					:    Tuple      							= temp.next
			lowerCAmelCase					:    Dict      							= temp.next
			lowerCAmelCase					:    Tuple      							= temp.next.next
		return delete_node.data



	def 				lowercase     (					self    ):
		return self.head is None



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    List[Any]      							= None
		lowerCAmelCase					:    Any      							= self.head

		while current:
			# Store the current node's next node.
			lowerCAmelCase					:    List[str]      							= current.next
			# Make the current node's next point backwards
			lowerCAmelCase					:    int      							= prev
			# Make the previous node be the current node
			lowerCAmelCase					:    int      							= current
			# Make the current node the next node (to progress iteration)
			lowerCAmelCase					:    Optional[Any]      							= next_node
		# Return prev in order to put the head at the end
		lowerCAmelCase					:    List[Any]      							= prev


def 			__UpperCamelCase    (    )    ->      None:




	"""simple docstring"""





	lowerCAmelCase					:    Tuple      							= LinkedList()
	assert linked_list.is_empty() is True
	assert str(_A				) == ""

	try:
		linked_list.delete_head()
		raise AssertionError  # This should not happen.
	except IndexError:
		assert True  # This should happen.

	try:
		linked_list.delete_tail()
		raise AssertionError  # This should not happen.
	except IndexError:
		assert True  # This should happen.

	for i in range(10				):
		assert len(_A				) == i
		linked_list.insert_nth(_A					,   i + 1				)
	assert str(_A				) == "->".join(str(_A				) for i in range(1					,   11				)				)

	linked_list.insert_head(0				)
	linked_list.insert_tail(11				)
	assert str(_A				) == "->".join(str(_A				) for i in range(0					,   12				)				)

	assert linked_list.delete_head() == 0
	assert linked_list.delete_nth(9				) == 10
	assert linked_list.delete_tail() == 11
	assert len(_A				) == 9
	assert str(_A				) == "->".join(str(_A				) for i in range(1					,   10				)				)

	assert all(linked_list[i] == i + 1 for i in range(0					,   9				)				) is True

	for i in range(0					,   9				):
		lowerCAmelCase					:    Optional[Any]      							= -i
	assert all(linked_list[i] == -i for i in range(0					,   9				)				) is True

	linked_list.reverse()
	assert str(_A				) == "->".join(str(_A				) for i in range(-8					,   1				)				)

def 			__UpperCamelCase    (    )    ->      None:




	"""simple docstring"""





	lowerCAmelCase					:    Optional[int]      							= [
	    -9,
	    1_00,
	    Node(77_34_51_12				),
	    'dlrow olleH',
	    7,
	    55_55,
	    0,
	    -1_92.5_55_55,
	    'Hello, world!',
	    77.9,
	    Node(10				),
	    None,
	    None,
	    12.20,
	]
	lowerCAmelCase					:    Dict      							= LinkedList()

	for i in test_input:
		linked_list.insert_tail(_A				)

	# Check if it's empty or not
	assert linked_list.is_empty() is False
	assert (
	    str(_A				) == "-9->100->Node(77345112)->dlrow olleH->7->5555->0->"
	    "-192.55555->Hello, world!->77.9->Node(10)->None->None->12.2"
	)

	# Delete the head
	lowerCAmelCase					:    Optional[Any]      							= linked_list.delete_head()
	assert result == -9
	assert (
	    str(_A				) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
	    "Hello, world!->77.9->Node(10)->None->None->12.2"
	)

	# Delete the tail
	lowerCAmelCase					:    List[str]      							= linked_list.delete_tail()
	assert result == 12.2
	assert (
	    str(_A				) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
	    "Hello, world!->77.9->Node(10)->None->None"
	)

	# Delete a node in specific location in linked list
	lowerCAmelCase					:    List[str]      							= linked_list.delete_nth(10				)
	assert result is None
	assert (
	    str(_A				) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
	    "Hello, world!->77.9->Node(10)->None"
	)

	# Add a Node instance to its head
	linked_list.insert_head(Node('Hello again, world!'				)				)
	assert (
	    str(_A				)
	    == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
	    "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None"
	)

	# Add None to its tail
	linked_list.insert_tail(_A				)
	assert (
	    str(_A				)
	    == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
	    "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None->None"
	)

	# Reverse the linked list
	linked_list.reverse()
	assert (
	    str(_A				)
	    == "None->None->Node(10)->77.9->Hello, world!->-192.55555->0->5555->"
	    "7->dlrow olleH->Node(77345112)->100->Node(Hello again, world!)"
	)

def 			__UpperCamelCase    (    )    ->      List[Any]:




	"""simple docstring"""





	from doctest import testmod

	testmod()

	lowerCAmelCase					:    Optional[Any]      							= LinkedList()
	linked_list.insert_head(input('Inserting 1st at head '				).strip()				)
	linked_list.insert_head(input('Inserting 2nd at head '				).strip()				)
	print('\nPrint list:'				)
	linked_list.print_list()
	linked_list.insert_tail(input('\nInserting 1st at tail '				).strip()				)
	linked_list.insert_tail(input('Inserting 2nd at tail '				).strip()				)
	print('\nPrint list:'				)
	linked_list.print_list()
	print('\nDelete head'				)
	linked_list.delete_head()
	print('Delete tail'				)
	linked_list.delete_tail()
	print('\nPrint list:'				)
	linked_list.print_list()
	print('\nReverse linked list'				)
	linked_list.reverse()
	print('\nPrint list:'				)
	linked_list.print_list()
	print('\nString representation of linked list:'				)
	print(_A				)
	print('\nReading/changing Node data using indexing:'				)
	print(F"Element at Position 1: {linked_list[1]}"				)
	lowerCAmelCase					:    Tuple      							= input('Enter New Value: '				).strip()
	print('New list:'				)
	print(_A				)
	print(F"length of linked_list is : {len(_A				)}"				)


if __name__ == "__main__":
				main()
