
'''simple docstring'''







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_video_inputs


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import VivitImageProcessor


class 		__UpperCAmelCase   (      unittest.TestCase		):


							def __init__( self					,     lowerCAmelCase_					,     lowerCAmelCase_=7					,     lowerCAmelCase_=3					,     lowerCAmelCase_=10					,     lowerCAmelCase_=18					,     lowerCAmelCase_=30					,     lowerCAmelCase_=4_00					,     lowerCAmelCase_=True					,     lowerCAmelCase_=None					,     lowerCAmelCase_=True					,     lowerCAmelCase_=[0.5, 0.5, 0.5]					,     lowerCAmelCase_=[0.5, 0.5, 0.5]					,     lowerCAmelCase_=None					,     ):





								"""simple docstring"""






								_snake_case     		=	size if size is not None else {"""shortest_edge""": 18}
								_snake_case     		=	crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

								_snake_case     		=	parent
								_snake_case     		=	batch_size
								_snake_case     		=	num_channels
								_snake_case     		=	num_frames
								_snake_case     		=	image_size
								_snake_case     		=	min_resolution
								_snake_case     		=	max_resolution
								_snake_case     		=	do_resize
								_snake_case     		=	size
								_snake_case     		=	do_normalize
								_snake_case     		=	image_mean
								_snake_case     		=	image_std
								_snake_case     		=	crop_size




							def 				lowerCamelCase       ( self						):





								"""simple docstring"""






								return {
								    "image_mean": self.image_mean,
								    "image_std": self.image_std,
								    "do_normalize": self.do_normalize,
								    "do_resize": self.do_resize,
								    "size": self.size,
								    "crop_size": self.crop_size,
								}


@require_torch
@require_vision
class 		__UpperCAmelCase   (      A_		,     unittest.TestCase		):
							__lowercase   	= VivitImageProcessor if is_vision_available() else None


							def 				lowerCamelCase       ( self						):





								"""simple docstring"""






								_snake_case     		=	VivitImageProcessingTester(self						)


							@property
							def 				lowerCamelCase       ( self						):





								"""simple docstring"""






								return self.image_processor_tester.prepare_image_processor_dict()


							def 				lowerCamelCase       ( self						):





								"""simple docstring"""






								_snake_case     		=	self.image_processing_class(**self.image_processor_dict						)
								self.assertTrue(hasattr(lowerCAmelCase_					,     'image_mean'						)						)
								self.assertTrue(hasattr(lowerCAmelCase_					,     'image_std'						)						)
								self.assertTrue(hasattr(lowerCAmelCase_					,     'do_normalize'						)						)
								self.assertTrue(hasattr(lowerCAmelCase_					,     'do_resize'						)						)
								self.assertTrue(hasattr(lowerCAmelCase_					,     'do_center_crop'						)						)
								self.assertTrue(hasattr(lowerCAmelCase_					,     'size'						)						)


							def 				lowerCamelCase       ( self						):





								"""simple docstring"""






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

								_snake_case     		=	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"""






								_snake_case     		=	self.image_processing_class(**self.image_processor_dict						)
								# create random PIL videos
								_snake_case     		=	prepare_video_inputs(self.image_processor_tester					,     equal_resolution=lowerCAmelCase_						)
								for video in video_inputs:
									self.assertIsInstance(lowerCAmelCase_					,     lowerCAmelCase_						)
									self.assertIsInstance(video[0]					,     Image.Image						)

								# Test not batched input
								_snake_case     		=	image_processing(video_inputs[0]					,     return_tensors='pt'						).pixel_values
								self.assertEqual(
								    encoded_videos.shape					,     (
								        1,
								        self.image_processor_tester.num_frames,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,     )

								# Test batched
								_snake_case     		=	image_processing(lowerCAmelCase_					,     return_tensors='pt'						).pixel_values
								self.assertEqual(
								    encoded_videos.shape					,     (
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_frames,
								        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"""






								_snake_case     		=	self.image_processing_class(**self.image_processor_dict						)
								# create random numpy tensors
								_snake_case     		=	prepare_video_inputs(self.image_processor_tester					,     equal_resolution=lowerCAmelCase_					,     numpify=lowerCAmelCase_						)
								for video in video_inputs:
									self.assertIsInstance(lowerCAmelCase_					,     lowerCAmelCase_						)
									self.assertIsInstance(video[0]					,     np.ndarray						)

								# Test not batched input
								_snake_case     		=	image_processing(video_inputs[0]					,     return_tensors='pt'						).pixel_values
								self.assertEqual(
								    encoded_videos.shape					,     (
								        1,
								        self.image_processor_tester.num_frames,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,     )

								# Test batched
								_snake_case     		=	image_processing(lowerCAmelCase_					,     return_tensors='pt'						).pixel_values
								self.assertEqual(
								    encoded_videos.shape					,     (
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_frames,
								        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"""






								_snake_case     		=	self.image_processing_class(**self.image_processor_dict						)
								# create random PyTorch tensors
								_snake_case     		=	prepare_video_inputs(self.image_processor_tester					,     equal_resolution=lowerCAmelCase_					,     torchify=lowerCAmelCase_						)
								for video in video_inputs:
									self.assertIsInstance(lowerCAmelCase_					,     lowerCAmelCase_						)
									self.assertIsInstance(video[0]					,     torch.Tensor						)

								# Test not batched input
								_snake_case     		=	image_processing(video_inputs[0]					,     return_tensors='pt'						).pixel_values
								self.assertEqual(
								    encoded_videos.shape					,     (
								        1,
								        self.image_processor_tester.num_frames,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,     )

								# Test batched
								_snake_case     		=	image_processing(lowerCAmelCase_					,     return_tensors='pt'						).pixel_values
								self.assertEqual(
								    encoded_videos.shape					,     (
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_frames,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.crop_size['height'],
								        self.image_processor_tester.crop_size['width'],
								    )					,     )






'''simple docstring'''







from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403







def        SCREAMING_SNAKE_CASE__			(     __A    ,       __A    ,       __A = "x"    ,       __A = 10**-10    ,       __A = 1    ,       ) ->			complex:
	_snake_case     		=	symbols(__A			)
	_snake_case     		=	lambdify(__A    ,       __A			)
	_snake_case     		=	lambdify(__A    ,       diff(__A    ,       __A			)			)

	_snake_case     		=	starting_point

	while True:
		if diff_function(__A			) != 0:
			_snake_case     		=	prev_guess - multiplicity * func(__A			) / diff_function(
			    __A			)
		else:
			raise ZeroDivisionError('Could not find root'			) from None

		# Precision is checked by comparing the difference of consecutive guesses
		if abs(next_guess - prev_guess			) < precision:
			return next_guess

		_snake_case     		=	next_guess


# Let's Execute
if __name__ == "__main__":
					# Find root of trigonometric function
					# Find value of pi
					print(F'''The root of sin(x) = 0 is {newton_raphson("sin(x)", 2)}''')

					# Find root of polynomial
					# Find fourth Root of 5
					print(F'''The root of x**4 - 5 = 0 is {newton_raphson("x**4 -5", 0.4 +5J)}''')

					# Find value of e
					print(
					    "The root of log(y) - 1 = 0 is ",
					    F'''{newton_raphson("log(y) - 1", 2, variable="y")}''',
					)

					# Exponential Roots
					print(
					    "The root of exp(x) - 1 = 0 is",
					    F'''{newton_raphson("exp(x) - 1", 10, precision=0.005)}''',
					)

					# Find root of cos(x)
					print(F'''The root of cos(x) = 0 is {newton_raphson("cos(x)", 0)}''')

