
'''simple docstring'''







from functools import partial
from typing import Any, Callable, Dict, List, Type, TypeVar, Union, overload

import torch
import torch.nn as nn
import torch.types
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				bool							):



						"""simple docstring"""





						if not inplace:
												lowercase_			:  Any									= ma + ma
						else:
												ma += ma

						return ma
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				List[int]							):



						"""simple docstring"""





						lowercase_			:  int									= -1 * len(__SCREAMING_SNAKE_CASE							)
						lowercase_			:  Union[str, Any]									= list(range(len(tensor.shape[:zero_index]							)							)							)
						return tensor.permute(first_inds + [zero_index + i for i in inds]							)
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				int							):



						"""simple docstring"""





						return t.reshape(t.shape[:-no_dims] + (-1,)							)
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				float = 1E-4							):



						"""simple docstring"""





						lowercase_			:  Optional[int]									= mask.expand(*value.shape							)
						return torch.sum(mask * value   ,   dim=__SCREAMING_SNAKE_CASE							) / (eps + torch.sum(__SCREAMING_SNAKE_CASE   ,   dim=__SCREAMING_SNAKE_CASE							))
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				torch.types.Number = 2.3125   ,   __SCREAMING_SNAKE_CASE      :				torch.types.Number = 21.6875   ,   __SCREAMING_SNAKE_CASE      :				int = 64							):



						"""simple docstring"""





						lowercase_			:  Optional[int]									= torch.linspace(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   no_bins - 1   ,   device=pts.device							)
						lowercase_			:  Optional[int]									= torch.sqrt(torch.sum((pts.unsqueeze(-2							) - pts.unsqueeze(-3							)) ** 2   ,   dim=-1							)							)
						return torch.bucketize(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Callable[[list], Any]   ,   __SCREAMING_SNAKE_CASE      :				List[dict]							):



						"""simple docstring"""





						lowercase_			:  Optional[Any]									= dicts[0]
						lowercase_			:  Optional[int]									= {}
						for k, v in first.items():
												lowercase_			:  Optional[Any]									= [d[k] for d in dicts]
												if isinstance(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							):
																		lowercase_			:  Tuple									= dict_multimap(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)
												else:
																		lowercase_			:  Tuple									= fn(__SCREAMING_SNAKE_CASE							)

						return new_dict
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				torch.Tensor							):



						"""simple docstring"""





						lowercase_			:  int									= v_bins.view(((1,) * len(x.shape							)) + (len(__SCREAMING_SNAKE_CASE							),)							)
						lowercase_			:  Union[str, Any]									= x[..., None] - reshaped_bins
						lowercase_			:  int									= torch.argmin(torch.abs(__SCREAMING_SNAKE_CASE							)   ,   dim=-1							)
						return nn.functional.one_hot(__SCREAMING_SNAKE_CASE   ,   num_classes=len(__SCREAMING_SNAKE_CASE							)							).float()
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				torch.Tensor   ,   __SCREAMING_SNAKE_CASE      :				int = 0   ,   __SCREAMING_SNAKE_CASE      :				int = 0							):



						"""simple docstring"""





						lowercase_			:  List[Union[slice, torch.Tensor]]									= []
						for i, s in enumerate(data.shape[:no_batch_dims]							):
												lowercase_			:  Optional[Any]									= torch.arange(__SCREAMING_SNAKE_CASE							)
												lowercase_			:  Dict									= r.view(*(*((1,) * i), -1, *((1,) * (len(inds.shape							) - i - 1)))							)
												ranges.append(__SCREAMING_SNAKE_CASE							)

						lowercase_			:  List[Union[slice, torch.Tensor]]									= [slice(__SCREAMING_SNAKE_CASE							) for _ in range(len(data.shape							) - no_batch_dims							)]
						lowercase_			:  Any									= inds
						ranges.extend(__SCREAMING_SNAKE_CASE							)
						# Matt note: Editing this to get around the behaviour of using a list as an array index changing
						# in recent Numpy versions
						return data[tuple(__SCREAMING_SNAKE_CASE							)]


_lowercase				:						Optional[Any]												= TypeVar("T")
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Callable[[T], Any]   ,   __SCREAMING_SNAKE_CASE      :				Dict[Any, Union[dict, list, tuple, T]]   ,   __SCREAMING_SNAKE_CASE      :				Type[T]							):



						"""simple docstring"""





						lowercase_			:  Dict[Any, Union[dict, list, tuple, Any]]									= {}
						for k, v in dic.items():
												if isinstance(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							):
																		lowercase_			:  str									= dict_map(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)
												else:
																		lowercase_			:  List[Any]									= tree_map(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)

						return new_dict
@overload
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Callable[[T], Any]   ,   __SCREAMING_SNAKE_CASE      :				T   ,   __SCREAMING_SNAKE_CASE      :				Type[T]							):



						"""simple docstring"""





						...
@overload
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Callable[[T], Any]   ,   __SCREAMING_SNAKE_CASE      :				dict   ,   __SCREAMING_SNAKE_CASE      :				Type[T]							):



						"""simple docstring"""





						...
@overload
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Callable[[T], Any]   ,   __SCREAMING_SNAKE_CASE      :				list   ,   __SCREAMING_SNAKE_CASE      :				Type[T]							):



						"""simple docstring"""





						...
@overload
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Callable[[T], Any]   ,   __SCREAMING_SNAKE_CASE      :				tuple   ,   __SCREAMING_SNAKE_CASE      :				Type[T]							):



						"""simple docstring"""





						...
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				Optional[Any]   ,   __SCREAMING_SNAKE_CASE      :				Any   ,   __SCREAMING_SNAKE_CASE      :				Dict							):



						"""simple docstring"""





						if isinstance(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							):
												return dict_map(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)
						elif isinstance(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							):
												return [tree_map(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							) for x in tree]
						elif isinstance(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							):
												return tuple(tree_map(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							) for x in tree							)
						elif isinstance(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							):
												return fn(__SCREAMING_SNAKE_CASE							)
						else:
												print(type(__SCREAMING_SNAKE_CASE							)							)
												raise ValueError('''Not supported'''							)




_lowercase				:						Optional[Any]												= partial(tree_map, leaf_type=torch.Tensor)





'''simple docstring'''







from itertools import combinations, product
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				int							):



						"""simple docstring"""





						if xa == ya == 0 or xa == ya == 0:
												return False
						lowercase_			:  Optional[Any]									= xa * xa + ya * ya
						lowercase_			:  List[str]									= xa * xa + ya * ya
						lowercase_			:  Any									= (xa - xa) * (xa - xa) + (ya - ya) * (ya - ya)
						return (
						    a_square + b_square == c_square
						    or a_square + c_square == b_square
						    or b_square + c_square == a_square
						)
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int = 50							):



						"""simple docstring"""





						return sum(
						    1
						    for pta, pta in combinations(product(range(limit + 1							)   ,   repeat=2							)   ,   2							)
						    if is_right(*__SCREAMING_SNAKE_CASE   ,   *__SCREAMING_SNAKE_CASE							)							)


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



