
from __future__ import annotations

from collections.abc import Callable






def   lowerCamelCase__							(							__lowerCAmelCase    :    Callable[[int | float], int | float]       ,				__lowerCAmelCase    :    int | float       ,				__lowerCAmelCase    :    int | float       ,				__lowerCAmelCase    :    int = 100       ,				):




			"""simple docstring"""


			lowerCAmelCase_         =      x_start
			lowerCAmelCase_         =      fnc(__lowerCAmelCase							)
			lowerCAmelCase_         =      0.0
			for _ in range(__lowerCAmelCase							):
						# Approximates small segments of curve as linear and solve
						# for trapezoidal area
						lowerCAmelCase_         =      (x_end - x_start) / steps + xa
						lowerCAmelCase_         =      fnc(__lowerCAmelCase							)
						area += abs(fxa + fxa							) * (xa - xa) / 2
						# Increment step
						lowerCAmelCase_         =      xa
						lowerCAmelCase_         =      fxa
			return area


if __name__ == "__main__":






			def   lowerCamelCase__							(							__lowerCAmelCase    :    List[Any]							):




						"""simple docstring"""


						return x**3 + x**2

			print("f(x) = x^3 + x^2")
			print("The area between the curve, x = -5, x = 5 and the x axis is:")
			_A  =	10
			while i <= 10_00_00:
						print(f"""with {i} steps: {trapezoidal_area(f, -5, 5, i)}""")
						i *= 10





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							)							)



