





"""simple docstring"""
import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
			import torch

			from transformers import MaskFormerForInstanceSegmentation, MaskFormerModel

			if is_vision_available():
						from transformers import MaskFormerImageProcessor

if is_vision_available():
			from PIL import Image


class 							lowerCamelCase_:





					'''simple docstring'''



					def __init__(    self				,       lowerCamelCase__				,       lowerCamelCase__=2				,       lowerCamelCase__=True				,       lowerCamelCase__=False				,       lowerCamelCase__=1_0				,       lowerCamelCase__=3				,       lowerCamelCase__=3_2 * 4				,       lowerCamelCase__=3_2 * 6				,       lowerCamelCase__=4				,       lowerCamelCase__=3_2				,       ):
									_lowerCamelCase        =				parent
									_lowerCamelCase        =				batch_size
									_lowerCamelCase        =				is_training
									_lowerCamelCase        =				use_auxiliary_loss
									_lowerCamelCase        =				num_queries
									_lowerCamelCase        =				num_channels
									_lowerCamelCase        =				min_size
									_lowerCamelCase        =				max_size
									_lowerCamelCase        =				num_labels
									_lowerCamelCase        =				mask_feature_size

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]   ).to(
									    lowerCamelCase__   )

									_lowerCamelCase        =				torch.ones([self.batch_size, self.min_size, self.max_size]				,       device=lowerCamelCase__   )

									_lowerCamelCase        =				(
									    torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]				,       device=lowerCamelCase__   ) > 0.5
									).float()
									_lowerCamelCase        =				(torch.rand((self.batch_size, self.num_labels)				,       device=lowerCamelCase__   ) > 0.5).long()

									_lowerCamelCase        =				self.get_config()
									return config, pixel_values, pixel_mask, mask_labels, class_labels

					def 			snake_case__      (    self   ):
									return MaskFormerConfig.from_backbone_and_decoder_configs(
									    backbone_config=SwinConfig(
									        depths=[1, 1, 1, 1]				,       )				,       decoder_config=DetrConfig(
									        decoder_ffn_dim=1_2_8				,       num_queries=self.num_queries				,       decoder_attention_heads=2				,       d_model=self.mask_feature_size				,       )				,       mask_feature_size=self.mask_feature_size				,       fpn_feature_size=self.mask_feature_size				,       num_channels=self.num_channels				,       num_labels=self.num_labels				,       )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.prepare_config_and_inputs()
									_lowerCamelCase        =				{'''pixel_values''': pixel_values, '''pixel_mask''': pixel_mask}
									return config, inputs_dict

					def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__   ):
									_lowerCamelCase        =				output.encoder_hidden_states
									_lowerCamelCase        =				output.pixel_decoder_hidden_states
									_lowerCamelCase        =				output.transformer_decoder_hidden_states

									self.parent.assertTrue(len(lowerCamelCase__   )				,       len(config.backbone_config.depths   )   )
									self.parent.assertTrue(len(lowerCamelCase__   )				,       len(config.backbone_config.depths   )   )
									self.parent.assertTrue(len(lowerCamelCase__   )				,       config.decoder_config.decoder_layers   )

					def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__=False   ):






									with torch.no_grad():
													_lowerCamelCase        =				MaskFormerModel(config=lowerCamelCase__   )
													model.to(lowerCamelCase__   )
													model.eval()

													_lowerCamelCase        =				model(pixel_values=lowerCamelCase__				,       pixel_mask=lowerCamelCase__   )
													_lowerCamelCase        =				model(lowerCamelCase__				,       output_hidden_states=lowerCamelCase__   )
									# the correct shape of output.transformer_decoder_hidden_states ensure the correcteness of the
									# encoder and pixel decoder
									self.parent.assertEqual(
									    output.transformer_decoder_last_hidden_state.shape				,       (self.batch_size, self.num_queries, self.mask_feature_size)				,       )
									# let's ensure the other two hidden state exists
									self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None   )
									self.parent.assertTrue(output.encoder_last_hidden_state is not None   )

									if output_hidden_states:
													self.check_output_hidden_state(lowerCamelCase__				,       lowerCamelCase__   )





					def 			snake_case__      (    self				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__				,       lowerCamelCase__   ):
									_lowerCamelCase        =				MaskFormerForInstanceSegmentation(config=lowerCamelCase__   )
									model.to(lowerCamelCase__   )
									model.eval()

									def comm_check_on_output(lowerCamelCase__   ):
													# let's still check that all the required stuff is there
													self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None   )
													self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None   )
													self.parent.assertTrue(result.encoder_last_hidden_state is not None   )
													# okay, now we need to check the logits shape
													# due to the encoder compression, masks have a //4 spatial size
													self.parent.assertEqual(
													    result.masks_queries_logits.shape				,       (self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)				,       )
													# + 1 for null class
													self.parent.assertEqual(
													    result.class_queries_logits.shape				,       (self.batch_size, self.num_queries, self.num_labels + 1)   )

									with torch.no_grad():
													_lowerCamelCase        =				model(pixel_values=lowerCamelCase__				,       pixel_mask=lowerCamelCase__   )
													_lowerCamelCase        =				model(lowerCamelCase__   )

													comm_check_on_output(lowerCamelCase__   )

													_lowerCamelCase        =				model(
													    pixel_values=lowerCamelCase__				,       pixel_mask=lowerCamelCase__				,       mask_labels=lowerCamelCase__				,       class_labels=lowerCamelCase__   )

									comm_check_on_output(lowerCamelCase__   )

									self.parent.assertTrue(result.loss is not None   )
									self.parent.assertEqual(result.loss.shape				,       torch.Size([1]   )   )


@require_torch
class 							lowerCamelCase_(   __lowerCAmelCase,				__lowerCAmelCase,				unittest.TestCase    ):





					'''simple docstring'''



					lowercase__   :       Optional[int]										= (MaskFormerModel, MaskFormerForInstanceSegmentation) if is_torch_available() else ()
					lowercase__   :       Dict										= (
					    {"feature-extraction": MaskFormerModel, "image-segmentation": MaskFormerForInstanceSegmentation}
					    if is_torch_available()
					    else {}
					)

					lowercase__   :       Union[str, Any]										= False
					lowercase__   :       Optional[Any]										= False
					lowercase__   :       Union[str, Any]										= False
					lowercase__   :       Optional[Any]										= False

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				MaskFormerModelTester(self   )
									_lowerCamelCase        =				ConfigTester(self				,       config_class=lowerCamelCase__				,       has_text_modality=lowerCamelCase__   )

					def 			snake_case__      (    self   ):
									self.config_tester.run_common_tests()

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs_for_common()
									self.model_tester.create_and_check_maskformer_model(lowerCamelCase__				,       **lowerCamelCase__				,       output_hidden_states=lowerCamelCase__   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_maskformer_instance_segmentation_head_model(*lowerCamelCase__   )

					@unittest.skip(reason='''MaskFormer does not use inputs_embeds'''   )
					def 			snake_case__      (    self   ):
									pass

					@unittest.skip(reason='''MaskFormer does not have a get_input_embeddings method'''   )
					def 			snake_case__      (    self   ):
									pass

					@unittest.skip(reason='''MaskFormer is not a generative model'''   )
					def 			snake_case__      (    self   ):
									pass

					@unittest.skip(reason='''MaskFormer does not use token embeddings'''   )
					def 			snake_case__      (    self   ):
									pass

					@require_torch_multi_gpu
					@unittest.skip(
					    reason='''MaskFormer has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`'''   )
					def 			snake_case__      (    self   ):
									pass

					@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''   )
					def 			snake_case__      (    self   ):
									pass

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs_for_common()

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

													_lowerCamelCase        =				['''pixel_values''']
													self.assertListEqual(arg_names[:1]				,       lowerCamelCase__   )

					@slow
					def 			snake_case__      (    self   ):






									for model_name in ["facebook/maskformer-swin-small-coco"]:
													_lowerCamelCase        =				MaskFormerModel.from_pretrained(lowerCamelCase__   )
													self.assertIsNotNone(lowerCamelCase__   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				(self.model_tester.min_size,) * 2
									_lowerCamelCase        =				{
									    '''pixel_values''': torch.randn((2, 3, *size)				,       device=lowerCamelCase__   ),
									    '''mask_labels''': torch.randn((2, 1_0, *size)				,       device=lowerCamelCase__   ),
									    '''class_labels''': torch.zeros(2				,       1_0				,       device=lowerCamelCase__   ).long(),
									}

									_lowerCamelCase        =				MaskFormerForInstanceSegmentation(MaskFormerConfig()   ).to(lowerCamelCase__   )
									_lowerCamelCase        =				model(**lowerCamelCase__   )
									self.assertTrue(outputs.loss is not None   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs_for_common()
									self.model_tester.create_and_check_maskformer_model(lowerCamelCase__				,       **lowerCamelCase__				,       output_hidden_states=lowerCamelCase__   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
													_lowerCamelCase        =				model_class(lowerCamelCase__   ).to(lowerCamelCase__   )
													_lowerCamelCase        =				model(**lowerCamelCase__				,       output_attentions=lowerCamelCase__   )
													self.assertTrue(outputs.attentions is not None   )

					def 			snake_case__      (    self   ):






									if not self.model_tester.is_training:
													return
									# only MaskFormerForInstanceSegmentation has the loss
									_lowerCamelCase        =				self.all_model_classes[1]
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs()

									_lowerCamelCase        =				model_class(lowerCamelCase__   )
									model.to(lowerCamelCase__   )
									model.train()

									_lowerCamelCase        =				model(lowerCamelCase__				,       mask_labels=lowerCamelCase__				,       class_labels=lowerCamelCase__   ).loss
									loss.backward()





					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				self.all_model_classes[1]
									_lowerCamelCase        =				self.model_tester.prepare_config_and_inputs()
									_lowerCamelCase        =				True
									_lowerCamelCase        =				True

									_lowerCamelCase        =				model_class(lowerCamelCase__   )
									model.to(lowerCamelCase__   )
									model.train()

									_lowerCamelCase        =				model(lowerCamelCase__				,       mask_labels=lowerCamelCase__				,       class_labels=lowerCamelCase__   )

									_lowerCamelCase        =				outputs.encoder_hidden_states[0]
									encoder_hidden_states.retain_grad()

									_lowerCamelCase        =				outputs.pixel_decoder_hidden_states[0]
									pixel_decoder_hidden_states.retain_grad()
									# we requires_grad=True in inputs_embeds (line 2152), the original implementation don't
									_lowerCamelCase        =				outputs.transformer_decoder_hidden_states[0]
									transformer_decoder_hidden_states.retain_grad()

									_lowerCamelCase        =				outputs.attentions[0]
									attentions.retain_grad()

									outputs.loss.backward(retain_graph=lowerCamelCase__   )

									self.assertIsNotNone(encoder_hidden_states.grad   )
									self.assertIsNotNone(pixel_decoder_hidden_states.grad   )
									self.assertIsNotNone(transformer_decoder_hidden_states.grad   )
									self.assertIsNotNone(attentions.grad   )
__SCREAMING_SNAKE_CASE  :						Optional[int]    							=      1e-4



def        lowerCAmelCase_(   )	->       Optional[Any]:
				_lowerCamelCase        =				Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							)
				return image




@require_vision
@slow
class 							lowerCamelCase_(   unittest.TestCase    ):





					'''simple docstring'''



					@cached_property
					def 			snake_case__      (    self   ):
									return (
									    MaskFormerImageProcessor.from_pretrained('''facebook/maskformer-swin-small-coco'''   )
									    if is_vision_available()
									    else None
									)

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				MaskFormerModel.from_pretrained('''facebook/maskformer-swin-small-coco'''   ).to(lowerCamelCase__   )
									_lowerCamelCase        =				self.default_image_processor
									_lowerCamelCase        =				prepare_img()
									_lowerCamelCase        =				image_processor(lowerCamelCase__				,       return_tensors='''pt'''   ).to(lowerCamelCase__   )
									_lowerCamelCase        =				inputs['''pixel_values'''].shape
									# check size is divisible by 32
									self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0   )
									# check size
									self.assertEqual(lowerCamelCase__				,       (1, 3, 8_0_0, 1_0_8_8)   )

									with torch.no_grad():
													_lowerCamelCase        =				model(**lowerCamelCase__   )

									_lowerCamelCase        =				torch.tensor(
									    [[-0.0_4_8_2, 0.9_2_2_8, 0.4_9_5_1], [-0.2_5_4_7, 0.8_0_1_7, 0.8_5_2_7], [-0.0_0_6_9, 0.3_3_8_5, -0.0_0_8_9]]   ).to(lowerCamelCase__   )
									self.assertTrue(
									    torch.allclose(
									        outputs.encoder_last_hidden_state[0, 0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )

									_lowerCamelCase        =				torch.tensor(
									    [[-0.8_4_2_2, -0.8_4_3_4, -0.9_7_1_8], [-1.0_1_4_4, -0.5_5_6_5, -0.4_1_9_5], [-1.0_0_3_8, -0.4_4_8_4, -0.1_9_6_1]]   ).to(lowerCamelCase__   )
									self.assertTrue(
									    torch.allclose(
									        outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )

									_lowerCamelCase        =				torch.tensor(
									    [[0.2_8_5_2, -0.0_1_5_9, 0.9_7_3_5], [0.6_2_5_4, 0.1_8_5_8, 0.8_5_2_9], [-0.0_6_8_0, -0.4_1_1_6, 1.8_4_1_3]]   ).to(lowerCamelCase__   )
									self.assertTrue(
									    torch.allclose(
									        outputs.transformer_decoder_last_hidden_state[0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				(
									    MaskFormerForInstanceSegmentation.from_pretrained('''facebook/maskformer-swin-small-coco'''   )
									    .to(lowerCamelCase__   )
									    .eval()
									)
									_lowerCamelCase        =				self.default_image_processor
									_lowerCamelCase        =				prepare_img()
									_lowerCamelCase        =				image_processor(lowerCamelCase__				,       return_tensors='''pt'''   ).to(lowerCamelCase__   )
									_lowerCamelCase        =				inputs['''pixel_values'''].shape
									# check size is divisible by 32
									self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0   )
									# check size
									self.assertEqual(lowerCamelCase__				,       (1, 3, 8_0_0, 1_0_8_8)   )

									with torch.no_grad():
													_lowerCamelCase        =				model(**lowerCamelCase__   )
									# masks_queries_logits
									_lowerCamelCase        =				outputs.masks_queries_logits
									self.assertEqual(
									    masks_queries_logits.shape				,       (1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)				,       )
									_lowerCamelCase        =				[
									    [-1.3_7_3_7_1_2_4, -1.7_7_2_4_9_3_7, -1.9_3_6_4_2_3_3],
									    [-1.5_9_7_7_2_8_1, -1.9_8_6_7_9_3_9, -2.1_5_2_3_6_9_5],
									    [-1.5_7_9_5_3_9_8, -1.9_2_6_9_8_3_2, -2.0_9_3_9_4_2],
									]
									_lowerCamelCase        =				torch.tensor(lowerCamelCase__   ).to(lowerCamelCase__   )
									self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )
									# class_queries_logits
									_lowerCamelCase        =				outputs.class_queries_logits
									self.assertEqual(
									    class_queries_logits.shape				,       (1, model.config.decoder_config.num_queries, model.config.num_labels + 1)   )
									_lowerCamelCase        =				torch.tensor(
									    [
									        [1.6512e00, -5.2572e00, -3.3519e00],
									        [3.6169e-02, -5.9025e00, -2.9313e00],
									        [1.0766e-04, -7.7630e00, -5.1263e00],
									    ]   ).to(lowerCamelCase__   )
									self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )

					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				(
									    MaskFormerForInstanceSegmentation.from_pretrained('''facebook/maskformer-resnet101-coco-stuff'''   )
									    .to(lowerCamelCase__   )
									    .eval()
									)
									_lowerCamelCase        =				self.default_image_processor
									_lowerCamelCase        =				prepare_img()
									_lowerCamelCase        =				image_processor(lowerCamelCase__				,       return_tensors='''pt'''   ).to(lowerCamelCase__   )
									_lowerCamelCase        =				inputs['''pixel_values'''].shape
									# check size is divisible by 32
									self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0   )
									# check size
									self.assertEqual(lowerCamelCase__				,       (1, 3, 8_0_0, 1_0_8_8)   )

									with torch.no_grad():
													_lowerCamelCase        =				model(**lowerCamelCase__   )
									# masks_queries_logits
									_lowerCamelCase        =				outputs.masks_queries_logits
									self.assertEqual(
									    masks_queries_logits.shape				,       (1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)				,       )
									_lowerCamelCase        =				[[-0.9_0_4_6, -2.6_3_6_6, -4.6_0_6_2], [-3.4_1_7_9, -5.7_8_9_0, -8.8_0_5_7], [-4.9_1_7_9, -7.6_5_6_0, -1_0.7_7_1_1]]
									_lowerCamelCase        =				torch.tensor(lowerCamelCase__   ).to(lowerCamelCase__   )
									self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )
									# class_queries_logits
									_lowerCamelCase        =				outputs.class_queries_logits
									self.assertEqual(
									    class_queries_logits.shape				,       (1, model.config.decoder_config.num_queries, model.config.num_labels + 1)   )
									_lowerCamelCase        =				torch.tensor(
									    [[4.7_1_8_8, -3.2_5_8_5, -2.8_8_5_7], [6.6_8_7_1, -2.9_1_8_1, -1.2_4_8_7], [7.2_4_4_9, -2.2_7_6_4, -2.1_8_7_4]]   ).to(lowerCamelCase__   )
									self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]				,       lowerCamelCase__				,       atol=lowerCamelCase__   )   )





					def 			snake_case__      (    self   ):
									_lowerCamelCase        =				(
									    MaskFormerForInstanceSegmentation.from_pretrained('''facebook/maskformer-swin-small-coco'''   )
									    .to(lowerCamelCase__   )
									    .eval()
									)
									_lowerCamelCase        =				self.default_image_processor

									_lowerCamelCase        =				image_processor(
									    [np.zeros((3, 8_0_0, 1_3_3_3)   ), np.zeros((3, 8_0_0, 1_3_3_3)   )]				,       segmentation_maps=[np.zeros((3_8_4, 3_8_4)   ).astype(np.floataa   ), np.zeros((3_8_4, 3_8_4)   ).astype(np.floataa   )]				,       return_tensors='''pt'''				,       )

									_lowerCamelCase        =				inputs['''pixel_values'''].to(lowerCamelCase__   )
									_lowerCamelCase        =				[el.to(lowerCamelCase__   ) for el in inputs['''mask_labels''']]
									_lowerCamelCase        =				[el.to(lowerCamelCase__   ) for el in inputs['''class_labels''']]

									with torch.no_grad():
													_lowerCamelCase        =				model(**lowerCamelCase__   )

									self.assertTrue(outputs.loss is not None   )





"""simple docstring"""
from itertools import zip_longest

import requests
from bsa import BeautifulSoup
from pandas import DataFrame



def        lowerCAmelCase_(   lowercase_     :							str = "laptop"							)	->       DataFrame:
				_lowerCamelCase        =				F"""https://www.amazon.in/laptop/s?k={product}"""
				_lowerCamelCase        =				{
				    '''User-Agent''': '''Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
        (KHTML, like Gecko)Chrome/44.0.2403.157 Safari/537.36''',
				    '''Accept-Language''': '''en-US, en;q=0.5''',
				}
				_lowerCamelCase        =				BeautifulSoup(requests.get(lowercase_						,   headers=lowercase_							).text							)
				# Initialize a Pandas dataframe with the column titles
				_lowerCamelCase        =				DataFrame(
				    columns=[
				        '''Product Title''',
				        '''Product Link''',
				        '''Current Price of the product''',
				        '''Product Rating''',
				        '''MRP of the product''',
				        '''Discount''',
				    ]							)
				# Loop through each entry and store them in the dataframe
				for item, _ in zip_longest(
				    soup.find_all(
				        '''div'''						,   attrs={'''class''': '''s-result-item''', '''data-component-type''': '''s-search-result'''}						,   )						,   soup.find_all('''div'''						,   attrs={'''class''': '''a-row a-size-base a-color-base'''}							)						,   ):
								try:
												_lowerCamelCase        =				item.ha.text
												_lowerCamelCase        =				'''https://www.amazon.in/''' + item.ha.a['''href''']
												_lowerCamelCase        =				item.find('''span'''						,   attrs={'''class''': '''a-offscreen'''}							).text
												try:
																_lowerCamelCase        =				item.find('''span'''						,   attrs={'''class''': '''a-icon-alt'''}							).text
												except AttributeError:
																_lowerCamelCase        =				'''Not available'''
												try:
																_lowerCamelCase        =				(
																    '''₹'''
																    + item.find(
																        '''span'''						,   attrs={'''class''': '''a-price a-text-price'''}							).text.split('''₹'''							)[1]
																)
												except AttributeError:
																_lowerCamelCase        =				''''''
												try:
																_lowerCamelCase        =				float(
																    (
																        (
																            float(product_mrp.strip('''₹'''							).replace(''','''						,   ''''''							)							)
																            - float(product_price.strip('''₹'''							).replace(''','''						,   ''''''							)							)
																        )
																        / float(product_mrp.strip('''₹'''							).replace(''','''						,   ''''''							)							)
																    )
																    * 1_00							)
												except ValueError:
																_lowerCamelCase        =				float('''nan'''							)
								except AttributeError:
												pass
								_lowerCamelCase        =				[
								    product_title,
								    product_link,
								    product_price,
								    product_rating,
								    product_mrp,
								    discount,
								]
				_lowerCamelCase        =				''' '''
				_lowerCamelCase        =				''' '''
				data_frame.index += 1
				return data_frame


if __name__ == "__main__":
			__SCREAMING_SNAKE_CASE  :						Optional[int]    							=      '''headphones'''
			get_amazon_product_data(product).to_csv(F"""Amazon Product Data for {product}.csv""")
