



import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
	import torch

if is_vision_available():
	from PIL import Image

	from transformers import MobileViTImageProcessor


class       _lowercase   (unittest.TestCase      ):
				'''simple docstring'''







				def __init__( self     , snake_case__     , snake_case__=7     , snake_case__=3     , snake_case__=18     , snake_case__=30     , snake_case__=400     , snake_case__=True     , snake_case__=None     , snake_case__=True     , snake_case__=None     , snake_case__=True     , ):

									'''simple docstring'''


									UpperCamelCase_		  =   size if size is not None else {"shortest_edge": 20}
									UpperCamelCase_		  =   crop_size if crop_size is not None else {"height": 18, "width": 18}
									UpperCamelCase_		  =   parent
									UpperCamelCase_		  =   batch_size
									UpperCamelCase_		  =   num_channels
									UpperCamelCase_		  =   image_size
									UpperCamelCase_		  =   min_resolution
									UpperCamelCase_		  =   max_resolution
									UpperCamelCase_		  =   do_resize
									UpperCamelCase_		  =   size
									UpperCamelCase_		  =   do_center_crop
									UpperCamelCase_		  =   crop_size
									UpperCamelCase_		  =   do_flip_channel_order

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									return {
									    "do_resize": self.do_resize,
									    "size": self.size,
									    "do_center_crop": self.do_center_crop,
									    "crop_size": self.crop_size,
									    "do_flip_channel_order": self.do_flip_channel_order,
									}




@require_torch
@require_vision
class       _lowercase   (a_      ,   unittest.TestCase      ):
				'''simple docstring'''







				lowercase__   						=						MobileViTImageProcessor if is_vision_available() else None

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									UpperCamelCase_		  =   MobileViTImageProcessingTester(self    )

				@property
				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									return self.image_processor_tester.prepare_image_processor_dict()

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									UpperCamelCase_		  =   self.image_processing_class(**self.image_processor_dict    )
									self.assertTrue(hasattr(snake_case__     , "do_resize"    )    )
									self.assertTrue(hasattr(snake_case__     , "size"    )    )
									self.assertTrue(hasattr(snake_case__     , "do_center_crop"    )    )
									self.assertTrue(hasattr(snake_case__     , "center_crop"    )    )
									self.assertTrue(hasattr(snake_case__     , "do_flip_channel_order"    )    )

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									UpperCamelCase_		  =   self.image_processing_class.from_dict(self.image_processor_dict    )
									self.assertEqual(image_processor.size     , {"shortest_edge": 20}    )
									self.assertEqual(image_processor.crop_size     , {"height": 18, "width": 18}    )

									UpperCamelCase_		  =   self.image_processing_class.from_dict(self.image_processor_dict     , size=42     , crop_size=84    )
									self.assertEqual(image_processor.size     , {"shortest_edge": 42}    )
									self.assertEqual(image_processor.crop_size     , {"height": 84, "width": 84}    )

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									pass

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									UpperCamelCase_		  =   self.image_processing_class(**self.image_processor_dict    )
									# create random PIL images
									UpperCamelCase_		  =   prepare_image_inputs(self.image_processor_tester     , equal_resolution=snake_case__    )
									for image in image_inputs:
														self.assertIsInstance(snake_case__     , Image.Image    )

									# Test not batched input
									UpperCamelCase_		  =   image_processing(image_inputs[0]     , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape     , (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["height"],
									        self.image_processor_tester.crop_size["width"],
									    )     , )

									# Test batched
									UpperCamelCase_		  =   image_processing(snake_case__     , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape     , (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["height"],
									        self.image_processor_tester.crop_size["width"],
									    )     , )

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									UpperCamelCase_		  =   self.image_processing_class(**self.image_processor_dict    )
									# create random numpy tensors
									UpperCamelCase_		  =   prepare_image_inputs(self.image_processor_tester     , equal_resolution=snake_case__     , numpify=snake_case__    )
									for image in image_inputs:
														self.assertIsInstance(snake_case__     , np.ndarray    )

									# Test not batched input
									UpperCamelCase_		  =   image_processing(image_inputs[0]     , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape     , (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["height"],
									        self.image_processor_tester.crop_size["width"],
									    )     , )

									# Test batched
									UpperCamelCase_		  =   image_processing(snake_case__     , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape     , (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["height"],
									        self.image_processor_tester.crop_size["width"],
									    )     , )

				def       _lowerCamelCase					( self    ):

									'''simple docstring'''


									UpperCamelCase_		  =   self.image_processing_class(**self.image_processor_dict    )
									# create random PyTorch tensors
									UpperCamelCase_		  =   prepare_image_inputs(self.image_processor_tester     , equal_resolution=snake_case__     , torchify=snake_case__    )
									for image in image_inputs:
														self.assertIsInstance(snake_case__     , torch.Tensor    )

									# Test not batched input
									UpperCamelCase_		  =   image_processing(image_inputs[0]     , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape     , (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["height"],
									        self.image_processor_tester.crop_size["width"],
									    )     , )

									# Test batched
									UpperCamelCase_		  =   image_processing(snake_case__     , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape     , (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["height"],
									        self.image_processor_tester.crop_size["width"],
									    )     , )





from __future__ import annotations



def    _lowerCAmelCase    (_lowerCAmelCase   ,	_lowerCAmelCase):
					if nth_term == "":
										return [""]
					UpperCamelCase_		  =   int(_lowerCAmelCase)
					UpperCamelCase_		  =   int(_lowerCAmelCase)
					UpperCamelCase_		  =   []
					for temp in range(int(_lowerCAmelCase)):
										series.append(f"""1 / {pow(temp + 1   ,	int(_lowerCAmelCase))}""" if series else "1")
					return series


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	UpperCAmelCase   :							Dict							 =int(input("""Enter the last number (nth term) of the P-Series"""))
	UpperCAmelCase   :							Union[str, Any]							 =int(input("""Enter the power for  P-Series"""))
	print("""Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p""")
	print(p_series(nth_term, power))
