
"""simple docstring"""




from __future__ import annotations

from decimal import Decimal
from math import *  # noqa: F403

from sympy import diff

def lowercase_    (  _snake_case  ,_snake_case  ,_snake_case = 10**-10		):
							SCREAMING_SNAKE_CASE__		:			Any	 =  a
							while True:
														SCREAMING_SNAKE_CASE__		:			Dict	 =  Decimal(__lowerCAmelCase		) - (
														    Decimal(eval(__lowerCAmelCase		)		) / Decimal(eval(str(diff(__lowerCAmelCase		)		)		)		)  # noqa: S307
														)
														# This number dictates the accuracy of the answer
														if abs(eval(__lowerCAmelCase		)		) < precision:  # noqa: S307
																					return float(__lowerCAmelCase		)


# 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
					print(f"""The root of x**2 - 5*x + 2 = 0 is {newton_raphson('x**2 - 5*x + 2', 0.4)}""")
					# Find Square Root of 5
					print(f"""The root of log(x) - 1 = 0 is {newton_raphson('log(x) - 1', 2)}""")
					# Exponential Roots
					print(f"""The root of exp(x) - 1 = 0 is {newton_raphson('exp(x) - 1', 0)}""")






from math import ceil






def   lowerCamelCase__							(							__lowerCAmelCase    :    Dict       ,				__lowerCAmelCase    :    int							):




			"""simple docstring"""


			lowerCAmelCase_         =      list(range(0       ,				__lowerCAmelCase							)							)

			lowerCAmelCase_         =      [item for sublist in list(device_map.values()							) for item in sublist]

			# Duplicate check
			lowerCAmelCase_         =      []
			for i in device_map_blocks:
						if device_map_blocks.count(__lowerCAmelCase							) > 1 and i not in duplicate_blocks:
									duplicate_blocks.append(__lowerCAmelCase							)
    # Missing blocks
			lowerCAmelCase_         =      [i for i in blocks if i not in device_map_blocks]
			lowerCAmelCase_         =      [i for i in device_map_blocks if i not in blocks]

			if len(__lowerCAmelCase							) != 0:
						raise ValueError(
						    "Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device."
						    " These attention blocks were specified more than once: " + str(__lowerCAmelCase							)							)
			if len(__lowerCAmelCase							) != 0:
						raise ValueError(
						    "There are attention blocks for this model that are not specified in the device_map. Add these attention "
						    "blocks to a device on the device_map: " + str(__lowerCAmelCase							)							)
			if len(__lowerCAmelCase							) != 0:
						raise ValueError(
						    "The device_map contains more attention blocks than this model has. Remove these from the device_map:"
						    + str(__lowerCAmelCase							)							)






def   lowerCamelCase__							(							__lowerCAmelCase    :    List[str]       ,				__lowerCAmelCase    :    Tuple							):




			"""simple docstring"""


			lowerCAmelCase_         =      list(range(__lowerCAmelCase							)							)
			lowerCAmelCase_         =      int(ceil(n_layers / len(__lowerCAmelCase							)							)							)
			lowerCAmelCase_         =      [layers[i : i + n_blocks] for i in range(0       ,				__lowerCAmelCase       ,				__lowerCAmelCase							)]

			return dict(zip(__lowerCAmelCase       ,				__lowerCAmelCase							)							)



