'''simple docstring'''




from copy import deepcopy
from typing import Optional, Union

import numpy as np

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
from ...utils import TensorType, is_tf_available, is_torch_available


if is_torch_available():
						import torch

if is_tf_available():
						import tensorflow as tf






class 				a__(					lowerCAmelCase__	):


			'''simple docstring'''






			UpperCAmelCase_			:     Optional[Any]      =       ['''image_processor''']
			UpperCAmelCase_			:     Tuple      =       '''SamImageProcessor'''



			def __init__(   self       ,    __lowerCAmelCase):




					"""simple docstring"""


					super().__init__(__lowerCAmelCase)
					lowerCAmelCase   					=  self.image_processor
					lowerCAmelCase   					=  -10
					lowerCAmelCase   					=  self.image_processor.size["""longest_edge"""]



			def __call__(   self       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase = None       ,    **__lowerCAmelCase       ,    ):




					"""simple docstring"""


					lowerCAmelCase   					=  self.image_processor(
					    __lowerCAmelCase       ,    return_tensors=__lowerCAmelCase       ,    **__lowerCAmelCase       ,    )

					# pop arguments that are not used in the foward but used nevertheless
					lowerCAmelCase   					=  encoding_image_processor["""original_sizes"""]

					if hasattr(__lowerCAmelCase       ,    """numpy"""):  # Checks if Torch or TF tensor
							lowerCAmelCase   					=  original_sizes.numpy()

					lowerCAmelCase					,     lowerCAmelCase					,     lowerCAmelCase   					=  self._check_and_preprocess_points(
					    input_points=__lowerCAmelCase       ,    input_labels=__lowerCAmelCase       ,    input_boxes=__lowerCAmelCase       ,    )

					lowerCAmelCase   					=  self._normalize_and_convert(
					    __lowerCAmelCase       ,    __lowerCAmelCase       ,    input_points=__lowerCAmelCase       ,    input_labels=__lowerCAmelCase       ,    input_boxes=__lowerCAmelCase       ,    return_tensors=__lowerCAmelCase       ,    )

					return encoding_image_processor



			def 							a_       (   self       ,    __lowerCAmelCase       ,    __lowerCAmelCase       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase="pt"       ,    ):




					"""simple docstring"""


					if input_points is not None:
							if len(__lowerCAmelCase) != len(__lowerCAmelCase):
									lowerCAmelCase   					=  [
									    self._normalize_coordinates(self.target_size       ,    __lowerCAmelCase       ,    original_sizes[0]) for point in input_points
									]
							else:
									lowerCAmelCase   					=  [
									    self._normalize_coordinates(self.target_size       ,    __lowerCAmelCase       ,    __lowerCAmelCase)
									    for point, original_size in zip(__lowerCAmelCase       ,    __lowerCAmelCase)
									]
							# check that all arrays have the same shape
							if not all(point.shape == input_points[0].shape for point in input_points):
									if input_labels is not None:
											lowerCAmelCase					,     lowerCAmelCase   					=  self._pad_points_and_labels(__lowerCAmelCase       ,    __lowerCAmelCase)

							lowerCAmelCase   					=  np.array(__lowerCAmelCase)

					if input_labels is not None:
							lowerCAmelCase   					=  np.array(__lowerCAmelCase)

					if input_boxes is not None:
							if len(__lowerCAmelCase) != len(__lowerCAmelCase):
									lowerCAmelCase   					=  [
									    self._normalize_coordinates(self.target_size       ,    __lowerCAmelCase       ,    original_sizes[0]       ,    is_bounding_box=__lowerCAmelCase)
									    for box in input_boxes
									]
							else:
									lowerCAmelCase   					=  [
									    self._normalize_coordinates(self.target_size       ,    __lowerCAmelCase       ,    __lowerCAmelCase       ,    is_bounding_box=__lowerCAmelCase)
									    for box, original_size in zip(__lowerCAmelCase       ,    __lowerCAmelCase)
									]
							lowerCAmelCase   					=  np.array(__lowerCAmelCase)

					if input_boxes is not None:
							if return_tensors == "pt":
									lowerCAmelCase   					=  torch.from_numpy(__lowerCAmelCase)
									# boxes batch size of 1 by default
									lowerCAmelCase   					=  input_boxes.unsqueeze(1) if len(input_boxes.shape) != 3 else input_boxes
							elif return_tensors == "tf":
									lowerCAmelCase   					=  tf.convert_to_tensor(__lowerCAmelCase)
									# boxes batch size of 1 by default
									lowerCAmelCase   					=  tf.expand_dims(__lowerCAmelCase       ,    1) if len(input_boxes.shape) != 3 else input_boxes
							encoding_image_processor.update({"""input_boxes""": input_boxes})
					if input_points is not None:
							if return_tensors == "pt":
									lowerCAmelCase   					=  torch.from_numpy(__lowerCAmelCase)
									# point batch size of 1 by default
									lowerCAmelCase   					=  input_points.unsqueeze(1) if len(input_points.shape) != 4 else input_points
							elif return_tensors == "tf":
									lowerCAmelCase   					=  tf.convert_to_tensor(__lowerCAmelCase)
									# point batch size of 1 by default
									lowerCAmelCase   					=  tf.expand_dims(__lowerCAmelCase       ,    1) if len(input_points.shape) != 4 else input_points
							encoding_image_processor.update({"""input_points""": input_points})
					if input_labels is not None:
							if return_tensors == "pt":
									lowerCAmelCase   					=  torch.from_numpy(__lowerCAmelCase)
									# point batch size of 1 by default
									lowerCAmelCase   					=  input_labels.unsqueeze(1) if len(input_labels.shape) != 3 else input_labels
							elif return_tensors == "tf":
									lowerCAmelCase   					=  tf.convert_to_tensor(__lowerCAmelCase)
									# point batch size of 1 by default
									lowerCAmelCase   					=  tf.expand_dims(__lowerCAmelCase       ,    1) if len(input_labels.shape) != 3 else input_labels
							encoding_image_processor.update({"""input_labels""": input_labels})

					return encoding_image_processor



			def 							a_       (   self       ,    __lowerCAmelCase       ,    __lowerCAmelCase):




					"""simple docstring"""


					lowerCAmelCase   					=  max([point.shape[0] for point in input_points])
					lowerCAmelCase   					=  []
					for i, point in enumerate(__lowerCAmelCase):
							if point.shape[0] != expected_nb_points:
									lowerCAmelCase   					=  np.concatenate(
									    [point, np.zeros((expected_nb_points - point.shape[0], 2)) + self.point_pad_value]       ,    axis=0)
									lowerCAmelCase   					=  np.append(input_labels[i]       ,    [self.point_pad_value])
							processed_input_points.append(__lowerCAmelCase)
					lowerCAmelCase   					=  processed_input_points
					return input_points, input_labels



			def 							a_       (   self       ,    __lowerCAmelCase       ,    __lowerCAmelCase       ,    __lowerCAmelCase       ,    __lowerCAmelCase=False):




					"""simple docstring"""


					lowerCAmelCase					,     lowerCAmelCase   					=  original_size
					lowerCAmelCase					,     lowerCAmelCase   					=  self.image_processor._get_preprocess_shape(__lowerCAmelCase       ,    longest_edge=__lowerCAmelCase)
					lowerCAmelCase   					=  deepcopy(__lowerCAmelCase).astype(__lowerCAmelCase)

					if is_bounding_box:
							lowerCAmelCase   					=  coords.reshape(-1       ,    2       ,    2)

					lowerCAmelCase   					=  coords[..., 0] * (new_w / old_w)
					lowerCAmelCase   					=  coords[..., 1] * (new_h / old_h)

					if is_bounding_box:
							lowerCAmelCase   					=  coords.reshape(-1       ,    4)

					return coords



			def 							a_       (   self       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    __lowerCAmelCase=None       ,    ):




					"""simple docstring"""


					if input_points is not None:
							if hasattr(__lowerCAmelCase       ,    """numpy"""):  # Checks for TF or Torch tensor
									lowerCAmelCase   					=  input_points.numpy().tolist()

							if not isinstance(__lowerCAmelCase       ,    __lowerCAmelCase) or not isinstance(input_points[0]       ,    __lowerCAmelCase):
									raise ValueError("""Input points must be a list of list of floating points.""")
							lowerCAmelCase   					=  [np.array(__lowerCAmelCase) for input_point in input_points]
					else:
							lowerCAmelCase   					=  None

					if input_labels is not None:
							if hasattr(__lowerCAmelCase       ,    """numpy"""):
									lowerCAmelCase   					=  input_labels.numpy().tolist()

							if not isinstance(__lowerCAmelCase       ,    __lowerCAmelCase) or not isinstance(input_labels[0]       ,    __lowerCAmelCase):
									raise ValueError("""Input labels must be a list of list integers.""")
							lowerCAmelCase   					=  [np.array(__lowerCAmelCase) for label in input_labels]
					else:
							lowerCAmelCase   					=  None

					if input_boxes is not None:
							if hasattr(__lowerCAmelCase       ,    """numpy"""):
									lowerCAmelCase   					=  input_boxes.numpy().tolist()

							if (
							    not isinstance(__lowerCAmelCase       ,    __lowerCAmelCase)
							    or not isinstance(input_boxes[0]       ,    __lowerCAmelCase)
							    or not isinstance(input_boxes[0][0]       ,    __lowerCAmelCase)
							):
									raise ValueError("""Input boxes must be a list of list of list of floating points.""")
							lowerCAmelCase   					=  [np.array(__lowerCAmelCase).astype(np.floataa) for box in input_boxes]
					else:
							lowerCAmelCase   					=  None

					return input_points, input_labels, input_boxes



			@property
			def 							a_       (   self):




					"""simple docstring"""


					lowerCAmelCase   					=  self.image_processor.model_input_names
					return list(dict.fromkeys(__lowerCAmelCase))







			def 							a_       (   self       ,    *__lowerCAmelCase       ,    **__lowerCAmelCase):




					"""simple docstring"""


					return self.image_processor.post_process_masks(*__lowerCAmelCase       ,    **__lowerCAmelCase)





'''simple docstring'''




from math import sqrt






def 				snake_case__							(			_A:					int = 1000000 )    ->	int:

		'''simple docstring'''


		lowerCAmelCase   					=  0
		lowerCAmelCase   					=  0
		lowerCAmelCase   					=  42

		while num_cuboids <= limit:
				max_cuboid_size += 1
				for sum_shortest_sides in range(2      ,   2 * max_cuboid_size + 1 ):
						if sqrt(sum_shortest_sides**2 + max_cuboid_size**2 ).is_integer():
								num_cuboids += (
								    min(_A      ,   sum_shortest_sides // 2 )
								    - max(1      ,   sum_shortest_sides - max_cuboid_size )
								    + 1
								)

		return max_cuboid_size


if __name__ == "__main__":
						print(f'{solution() = }')




