

"""simple docstring"""






import inspect
import unittest

from transformers import MobileViTConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTModel
	from transformers.models.mobilevit.modeling_mobilevit import MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import MobileViTImageProcessor







class       snake_case__  ( __lowercase     ):







			def 			__lowerCAmelCase				(			self			: Optional[Any]  ):





								'''simple docstring'''



								UpperCAmelCase			:   Tuple      =				self.config_class(**self.inputs_dict  )
								self.parent.assertTrue(hasattr(lowercase			,  "hidden_sizes"  )  )
								self.parent.assertTrue(hasattr(lowercase			,  "neck_hidden_sizes"  )  )
								self.parent.assertTrue(hasattr(lowercase			,  "num_attention_heads"  )  )







class       snake_case__  :







			def __init__(			self			: List[Any]			,  lowercase			: Optional[int]			,  lowercase			: Tuple=13			,  lowercase			: Union[str, Any]=32			,  lowercase			: int=2			,  lowercase			: Tuple=3			,  lowercase			: Optional[Any]=6_40			,  lowercase			: Dict=4			,  lowercase			: Optional[int]="silu"			,  lowercase			: Dict=3			,  lowercase			: List[str]=32			,  lowercase			: Union[str, Any]=0.1			,  lowercase			: List[str]=0.1			,  lowercase			: List[str]=0.1			,  lowercase			: Any=0.0_2			,  lowercase			: Union[str, Any]=True			,  lowercase			: Dict=True			,  lowercase			: Any=10			,  lowercase			: List[str]=None			,  ):





								'''simple docstring'''



								UpperCAmelCase			:   int      =				parent
								UpperCAmelCase			:   int      =				batch_size
								UpperCAmelCase			:   Any      =				image_size
								UpperCAmelCase			:   Optional[int]      =				patch_size
								UpperCAmelCase			:   List[Any]      =				num_channels
								UpperCAmelCase			:   Optional[Any]      =				last_hidden_size
								UpperCAmelCase			:   Optional[int]      =				num_attention_heads
								UpperCAmelCase			:   Any      =				hidden_act
								UpperCAmelCase			:   Any      =				conv_kernel_size
								UpperCAmelCase			:   str      =				output_stride
								UpperCAmelCase			:   Dict      =				hidden_dropout_prob
								UpperCAmelCase			:   Union[str, Any]      =				attention_probs_dropout_prob
								UpperCAmelCase			:   List[str]      =				classifier_dropout_prob
								UpperCAmelCase			:   str      =				use_labels
								UpperCAmelCase			:   Any      =				is_training
								UpperCAmelCase			:   Dict      =				num_labels
								UpperCAmelCase			:   Union[str, Any]      =				initializer_range
								UpperCAmelCase			:   Dict      =				scope







			def 			__lowerCAmelCase				(			self			: Tuple  ):





								'''simple docstring'''



								UpperCAmelCase			:   Tuple      =				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )

								UpperCAmelCase			:   Optional[int]      =				None
								UpperCAmelCase			:   Union[str, Any]      =				None
								if self.use_labels:
													UpperCAmelCase			:   int      =				ids_tensor([self.batch_size]			,  self.num_labels  )
													UpperCAmelCase			:   List[str]      =				ids_tensor([self.batch_size, self.image_size, self.image_size]			,  self.num_labels  )

								UpperCAmelCase			:   List[str]      =				self.get_config()

								return config, pixel_values, labels, pixel_labels







			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								return MobileViTConfig(
								    image_size=self.image_size			,  patch_size=self.patch_size			,  num_channels=self.num_channels			,  num_attention_heads=self.num_attention_heads			,  hidden_act=self.hidden_act			,  conv_kernel_size=self.conv_kernel_size			,  output_stride=self.output_stride			,  hidden_dropout_prob=self.hidden_dropout_prob			,  attention_probs_dropout_prob=self.attention_probs_dropout_prob			,  classifier_dropout_prob=self.classifier_dropout_prob			,  initializer_range=self.initializer_range			,  )







			def 			__lowerCAmelCase				(			self			: Optional[int]			,  lowercase			: Tuple			,  lowercase			: List[str]			,  lowercase			: Optional[int]			,  lowercase			: List[str]  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				MobileViTModel(config=lowercase  )
								model.to(lowercase  )
								model.eval()
								UpperCAmelCase			:   List[Any]      =				model(lowercase  )
								self.parent.assertEqual(
								    result.last_hidden_state.shape			,  (
								        self.batch_size,
								        self.last_hidden_size,
								        self.image_size // self.output_stride,
								        self.image_size // self.output_stride,
								    )			,  )







			def 			__lowerCAmelCase				(			self			: Union[str, Any]			,  lowercase			: Tuple			,  lowercase			: Any			,  lowercase			: int			,  lowercase			: Any  ):





								'''simple docstring'''



								UpperCAmelCase			:   int      =				self.num_labels
								UpperCAmelCase			:   int      =				MobileViTForImageClassification(lowercase  )
								model.to(lowercase  )
								model.eval()
								UpperCAmelCase			:   Union[str, Any]      =				model(lowercase			,  labels=lowercase  )
								self.parent.assertEqual(result.logits.shape			,  (self.batch_size, self.num_labels)  )







			def 			__lowerCAmelCase				(			self			: List[str]			,  lowercase			: Optional[int]			,  lowercase			: Optional[int]			,  lowercase			: int			,  lowercase			: List[str]  ):





								'''simple docstring'''



								UpperCAmelCase			:   Union[str, Any]      =				self.num_labels
								UpperCAmelCase			:   Any      =				MobileViTForSemanticSegmentation(lowercase  )
								model.to(lowercase  )
								model.eval()
								UpperCAmelCase			:   str      =				model(lowercase  )
								self.parent.assertEqual(
								    result.logits.shape			,  (
								        self.batch_size,
								        self.num_labels,
								        self.image_size // self.output_stride,
								        self.image_size // self.output_stride,
								    )			,  )
								UpperCAmelCase			:   Tuple      =				model(lowercase			,  labels=lowercase  )
								self.parent.assertEqual(
								    result.logits.shape			,  (
								        self.batch_size,
								        self.num_labels,
								        self.image_size // self.output_stride,
								        self.image_size // self.output_stride,
								    )			,  )







			def 			__lowerCAmelCase				(			self			: str  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				self.prepare_config_and_inputs()
								UpperCAmelCase			:   Tuple      =				config_and_inputs
								UpperCAmelCase			:   Tuple      =				{"pixel_values": pixel_values}
								return config, inputs_dict







@require_torch
class       snake_case__  ( __lowercase					,  __lowercase					,  unittest.TestCase     ):
			SCREAMING_SNAKE_CASE__     				=						(
			    (MobileViTModel, MobileViTForImageClassification, MobileViTForSemanticSegmentation)
			    if is_torch_available()
			    else ()
			)
			SCREAMING_SNAKE_CASE__     				=						(
			    {
			        '''feature-extraction''': MobileViTModel,
			        '''image-classification''': MobileViTForImageClassification,
			        '''image-segmentation''': MobileViTForSemanticSegmentation,
			    }
			    if is_torch_available()
			    else {}
			)

			SCREAMING_SNAKE_CASE__     				=						False
			SCREAMING_SNAKE_CASE__     				=						False
			SCREAMING_SNAKE_CASE__     				=						False
			SCREAMING_SNAKE_CASE__     				=						False







			def 			__lowerCAmelCase				(			self			: int  ):





								'''simple docstring'''



								UpperCAmelCase			:   str      =				MobileViTModelTester(self  )
								UpperCAmelCase			:   int      =				MobileViTConfigTester(self			,  config_class=lowercase			,  has_text_modality=lowercase  )







			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								self.config_tester.run_common_tests()







			@unittest.skip(reason="MobileViT does not use inputs_embeds"  )
			def 			__lowerCAmelCase				(			self			: List[str]  ):





								'''simple docstring'''



								pass







			@unittest.skip(reason="MobileViT does not support input and output embeddings"  )
			def 			__lowerCAmelCase				(			self			: List[str]  ):





								'''simple docstring'''



								pass







			@unittest.skip(reason="MobileViT does not output attentions"  )
			def 			__lowerCAmelCase				(			self			: List[str]  ):





								'''simple docstring'''



								pass







			def 			__lowerCAmelCase				(			self			: Any  ):





								'''simple docstring'''



								UpperCAmelCase			:   Any      =				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
													UpperCAmelCase			:   str      =				model_class(lowercase  )
													UpperCAmelCase			:   Dict      =				inspect.signature(model.forward  )
													# signature.parameters is an OrderedDict => so arg_names order is deterministic
													UpperCAmelCase			:   Dict      =				[*signature.parameters.keys()]

													UpperCAmelCase			:   Dict      =				["pixel_values"]
													self.assertListEqual(arg_names[:1]			,  lowercase  )







			@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."  )
			def 			__lowerCAmelCase				(			self			: Union[str, Any]  ):





								'''simple docstring'''



								pass







			def 			__lowerCAmelCase				(			self			: int  ):





								'''simple docstring'''



								UpperCAmelCase			:   Union[str, Any]      =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*lowercase  )







			def 			__lowerCAmelCase				(			self			: int  ):





								'''simple docstring'''



								def check_hidden_states_output(lowercase			: List[Any]			,  lowercase			: Optional[Any]			,  lowercase			: Any  ):
													UpperCAmelCase			:   str      =				model_class(lowercase  )
													model.to(lowercase  )
													model.eval()

													with torch.no_grad():
																		UpperCAmelCase			:   Any      =				model(**self._prepare_for_class(lowercase			,  lowercase  )  )

													UpperCAmelCase			:   Tuple      =				outputs.hidden_states

													UpperCAmelCase			:   Tuple      =				5
													self.assertEqual(len(lowercase  )			,  lowercase  )

													# MobileViT's feature maps are of shape (batch_size, num_channels, height, width)
													# with the width and height being successively divided by 2.
													UpperCAmelCase			:   Any      =				2
													for i in range(len(lowercase  )  ):
																		self.assertListEqual(
																		    list(hidden_states[i].shape[-2:]  )			,  [self.model_tester.image_size // divisor, self.model_tester.image_size // divisor]			,  )
																		divisor *= 2

													self.assertEqual(self.model_tester.output_stride			,  divisor // 2  )

								UpperCAmelCase			:   Any      =				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
													UpperCAmelCase			:   str      =				True
													check_hidden_states_output(lowercase			,  lowercase			,  lowercase  )

													# check that output_hidden_states also work using config
													del inputs_dict["output_hidden_states"]
													UpperCAmelCase			:   Any      =				True

													check_hidden_states_output(lowercase			,  lowercase			,  lowercase  )







			def 			__lowerCAmelCase				(			self			: Any  ):





								'''simple docstring'''



								UpperCAmelCase			:   Optional[Any]      =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*lowercase  )







			def 			__lowerCAmelCase				(			self			: Dict  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[str]      =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_semantic_segmentation(*lowercase  )







			@slow
			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								for model_name in MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													UpperCAmelCase			:   List[str]      =				MobileViTModel.from_pretrained(lowercase  )
													self.assertIsNotNone(lowercase  )



def   lowercase_	(    ):




					'''simple docstring'''






					UpperCAmelCase			:   List[Any]      =				Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"	)
					return image







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







			@cached_property
			def 			__lowerCAmelCase				(			self			: Tuple  ):





								'''simple docstring'''



								return MobileViTImageProcessor.from_pretrained("apple/mobilevit-xx-small"  ) if is_vision_available() else None







			@slow
			def 			__lowerCAmelCase				(			self			: Tuple  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				MobileViTForImageClassification.from_pretrained("apple/mobilevit-xx-small"  ).to(lowercase  )

								UpperCAmelCase			:   Dict      =				self.default_image_processor
								UpperCAmelCase			:   Optional[Any]      =				prepare_img()
								UpperCAmelCase			:   Union[str, Any]      =				image_processor(images=lowercase			,  return_tensors="pt"  ).to(lowercase  )

								# forward pass
								with torch.no_grad():
													UpperCAmelCase			:   str      =				model(**lowercase  )

								# verify the logits
								UpperCAmelCase			:   Optional[int]      =				torch.Size((1, 10_00)  )
								self.assertEqual(outputs.logits.shape			,  lowercase  )

								UpperCAmelCase			:   List[str]      =				torch.tensor([-1.9_3_6_4, -1.2_3_2_7, -0.4_6_5_3]  ).to(lowercase  )

								self.assertTrue(torch.allclose(outputs.logits[0, :3]			,  lowercase			,  atol=1E-4  )  )







			@slow
			def 			__lowerCAmelCase				(			self			: str  ):





								'''simple docstring'''



								UpperCAmelCase			:   Optional[Any]      =				MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small"  )
								UpperCAmelCase			:   Optional[int]      =				model.to(lowercase  )

								UpperCAmelCase			:   str      =				MobileViTImageProcessor.from_pretrained("apple/deeplabv3-mobilevit-xx-small"  )

								UpperCAmelCase			:   List[Any]      =				prepare_img()
								UpperCAmelCase			:   Tuple      =				image_processor(images=lowercase			,  return_tensors="pt"  ).to(lowercase  )

								# forward pass
								with torch.no_grad():
													UpperCAmelCase			:   int      =				model(**lowercase  )
								UpperCAmelCase			:   Any      =				outputs.logits

								# verify the logits
								UpperCAmelCase			:   List[Any]      =				torch.Size((1, 21, 32, 32)  )
								self.assertEqual(logits.shape			,  lowercase  )

								UpperCAmelCase			:   Optional[Any]      =				torch.tensor(
								    [
								        [[6.9_7_1_3, 6.9_7_8_6, 7.2_4_2_2], [7.2_8_9_3, 7.2_8_2_5, 7.4_4_4_6], [7.6_5_8_0, 7.8_7_9_7, 7.9_4_2_0]],
								        [[-1_0.6_8_6_9, -1_0.3_2_5_0, -1_0.3_4_7_1], [-1_0.4_2_2_8, -9.9_8_6_8, -9.7_1_3_2], [-1_1.0_4_0_5, -1_1.0_2_2_1, -1_0.7_3_1_8]],
								        [[-3.3_0_8_9, -2.8_5_3_9, -2.6_7_4_0], [-3.2_7_0_6, -2.5_6_2_1, -2.5_1_0_8], [-3.2_5_3_4, -2.6_6_1_5, -2.6_6_5_1]],
								    ]			,  device=lowercase			,  )

								self.assertTrue(torch.allclose(logits[0, :3, :3, :3]			,  lowercase			,  atol=1E-4  )  )







			@slow
			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								UpperCAmelCase			:   int      =				MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small"  )
								UpperCAmelCase			:   str      =				model.to(lowercase  )

								UpperCAmelCase			:   str      =				MobileViTImageProcessor.from_pretrained("apple/deeplabv3-mobilevit-xx-small"  )

								UpperCAmelCase			:   List[str]      =				prepare_img()
								UpperCAmelCase			:   List[Any]      =				image_processor(images=lowercase			,  return_tensors="pt"  ).to(lowercase  )

								# forward pass
								with torch.no_grad():
													UpperCAmelCase			:   List[Any]      =				model(**lowercase  )

								UpperCAmelCase			:   List[str]      =				outputs.logits.detach().cpu()

								UpperCAmelCase			:   Any      =				image_processor.post_process_semantic_segmentation(outputs=lowercase			,  target_sizes=[(50, 60)]  )
								UpperCAmelCase			:   Optional[Any]      =				torch.Size((50, 60)  )
								self.assertEqual(segmentation[0].shape			,  lowercase  )

								UpperCAmelCase			:   Optional[Any]      =				image_processor.post_process_semantic_segmentation(outputs=lowercase  )
								UpperCAmelCase			:   Union[str, Any]      =				torch.Size((32, 32)  )
								self.assertEqual(segmentation[0].shape			,  lowercase  )





"""simple docstring"""






from typing import Any







class       snake_case__  :







			def __init__(			self			: Union[str, Any]			,  lowercase			: Any  ):





								'''simple docstring'''



								UpperCAmelCase			:   Dict      =				data
								UpperCAmelCase			:   Optional[Any]      =				None







			def __repr__(			self			: str  ):





								'''simple docstring'''



								return f"""Node({self.data})"""







class       snake_case__  :







			def __init__(			self			: Optional[Any]  ):





								'''simple docstring'''



								UpperCAmelCase			:   Optional[Any]      =				None







			def __iter__(			self			: Dict  ):





								'''simple docstring'''



								UpperCAmelCase			:   str      =				self.head
								while node:
													yield node.data
													UpperCAmelCase			:   Tuple      =				node.next







			def __len__(			self			: Tuple  ):





								'''simple docstring'''



								return sum(1 for _ in self  )







			def __repr__(			self			: Any  ):





								'''simple docstring'''



								return "->".join([str(lowercase  ) for item in self]  )







			def __getitem__(			self			: List[str]			,  lowercase			: int  ):





								'''simple docstring'''



								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			: str			,  lowercase			: int			,  lowercase			: Any  ):





								'''simple docstring'''



								if not 0 <= index < len(self  ):
													raise ValueError("list index out of range."  )
								UpperCAmelCase			:   List[str]      =				self.head
								for _ in range(lowercase  ):
													UpperCAmelCase			:   List[Any]      =				current.next
								UpperCAmelCase			:   List[str]      =				data







			def 			__lowerCAmelCase				(			self			: Optional[Any]			,  lowercase			: Any  ):





								'''simple docstring'''



								self.insert_nth(len(self  )			,  lowercase  )







			def 			__lowerCAmelCase				(			self			: List[str]			,  lowercase			: Any  ):





								'''simple docstring'''



								self.insert_nth(0			,  lowercase  )







			def 			__lowerCAmelCase				(			self			: List[str]			,  lowercase			: int			,  lowercase			: Any  ):





								'''simple docstring'''



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







			def 			__lowerCAmelCase				(			self			: Dict  ):  # print every node data





								'''simple docstring'''



								print(self  )







			def 			__lowerCAmelCase				(			self			: Optional[Any]  ):





								'''simple docstring'''



								return self.delete_nth(0  )







			def 			__lowerCAmelCase				(			self			: str  ):  # delete from tail





								'''simple docstring'''



								return self.delete_nth(len(self  ) - 1  )







			def 			__lowerCAmelCase				(			self			: Optional[Any]			,  lowercase			: int = 0  ):





								'''simple docstring'''



								if not 0 <= index <= len(self  ) - 1:  # test if index is valid
													raise IndexError("List index out of range."  )
								UpperCAmelCase			:   List[str]      =				self.head  # default first node
								if index == 0:
													UpperCAmelCase			:   Tuple      =				self.head.next
								else:
													UpperCAmelCase			:   Union[str, Any]      =				self.head
													for _ in range(index - 1  ):
																		UpperCAmelCase			:   Dict      =				temp.next
													UpperCAmelCase			:   Optional[Any]      =				temp.next
													UpperCAmelCase			:   int      =				temp.next.next
								return delete_node.data







			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								return self.head is None







			def 			__lowerCAmelCase				(			self			: int  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				None
								UpperCAmelCase			:   str      =				self.head

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



def   lowercase_	(    ):




					'''simple docstring'''






					UpperCAmelCase			:   Optional[int]      =				LinkedList()
					assert linked_list.is_empty() is True
					assert str(_lowercase	) == ""

					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(_lowercase	) == i
										linked_list.insert_nth(_lowercase							,      i + 1	)
					assert str(_lowercase	) == "->".join(str(_lowercase	) for i in range(1							,      11	)	)

					linked_list.insert_head(0	)
					linked_list.insert_tail(11	)
					assert str(_lowercase	) == "->".join(str(_lowercase	) 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(_lowercase	) == 9
					assert str(_lowercase	) == "->".join(str(_lowercase	) 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	):
										UpperCAmelCase			:   Union[str, Any]      =				-i
					assert all(linked_list[i] == -i for i in range(0							,      9	)	) is True

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



def   lowercase_	(    ):




					'''simple docstring'''






					UpperCAmelCase			:   Optional[Any]      =				[
					    -9,
					    1_00,
					    Node(77_34_51_12	),
					    "dlrow olleH",
					    7,
					    55_55,
					    0,
					    -1_9_2.5_5_5_5_5,
					    "Hello, world!",
					    7_7.9,
					    Node(10	),
					    None,
					    None,
					    1_2.2_0,
					]
					UpperCAmelCase			:   Optional[Any]      =				LinkedList()

					for i in test_input:
										linked_list.insert_tail(_lowercase	)

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

					# Delete the head
					UpperCAmelCase			:   Tuple      =				linked_list.delete_head()
					assert result == -9
					assert (
					    str(_lowercase	) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
					    "Hello, world!->77.9->Node(10)->None->None->12.2"
					)

					# Delete the tail
					UpperCAmelCase			:   Any      =				linked_list.delete_tail()
					assert result == 1_2.2
					assert (
					    str(_lowercase	) == "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
					UpperCAmelCase			:   Union[str, Any]      =				linked_list.delete_nth(10	)
					assert result is None
					assert (
					    str(_lowercase	) == "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(_lowercase	)
					    == "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(_lowercase	)
					assert (
					    str(_lowercase	)
					    == "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(_lowercase	)
					    == "None->None->Node(10)->77.9->Hello, world!->-192.55555->0->5555->"
					    "7->dlrow olleH->Node(77345112)->100->Node(Hello again, world!)"
					)



def   lowercase_	(    ):




					'''simple docstring'''






					from doctest import testmod

					testmod()

					UpperCAmelCase			:   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(_lowercase	)
					print("\nReading/changing Node data using indexing:"	)
					print(F"""Element at Position 1: {linked_list[1]}"""	)
					UpperCAmelCase			:   int      =				input("Enter New Value: "	).strip()
					print("New list:"	)
					print(_lowercase	)
					print(F"""length of linked_list is : {len(_lowercase	)}"""	)


if __name__ == "__main__":
	main()


