


"""simple docstring"""







from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available






def        a__			(							_UpperCamelCase			):





						"""simple docstring"""

						if is_torch_available():
												import torch

												if isinstance(_UpperCamelCase						,      torch.Tensor			):
																		return True

						return isinstance(_UpperCamelCase						,      np.ndarray			)


class 				lowerCamelCase							(      __SCREAMING_SNAKE_CASE			):


							"""simple docstring"""






							def        lowerCAmelCase  (    self			:  Dict					):
													UpperCAmelCase__												=     fields(self					)

													# Safety and consistency checks
													if not len(lowerCamelCase_					):
																			raise ValueError(f"""{self.__class__.__name__} has no fields."""					)

													UpperCAmelCase__												=     getattr(self		,			class_fields[0].name					)
													UpperCAmelCase__												=     all(getattr(self		,			field.name					) is None for field in class_fields[1:]					)

													if other_fields_are_none and isinstance(lowerCamelCase_		,			lowerCamelCase_					):
																			for key, value in first_field.items():
																									UpperCAmelCase__												=     value
													else:
																			for field in class_fields:
																									UpperCAmelCase__												=     getattr(self		,			field.name					)
																									if v is not None:
																															UpperCAmelCase__												=     v






							def __delitem__(    self			:  str		,			*lowerCamelCase_			:  Tuple		,			**lowerCamelCase_			:  Tuple					):
													raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""					)






							def        lowerCAmelCase  (    self			:  Dict		,			*lowerCamelCase_			:  List[Any]		,			**lowerCamelCase_			:  Optional[Any]					):
													raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""					)






							def        lowerCAmelCase  (    self			:  str		,			*lowerCamelCase_			:  Dict		,			**lowerCamelCase_			:  str					):
													raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""					)






							def        lowerCAmelCase  (    self			:  str		,			*lowerCamelCase_			:  str		,			**lowerCamelCase_			:  Dict					):
													raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""					)






							def __getitem__(    self			:  Any		,			lowerCamelCase_			:  Optional[Any]					):
													if isinstance(lowerCamelCase_		,			lowerCamelCase_					):
																			UpperCAmelCase__												=     dict(self.items()					)
																			return inner_dict[k]
													else:
																			return self.to_tuple()[k]






							def __setattr__(    self			:  List[Any]		,			lowerCamelCase_			:  str		,			lowerCamelCase_			:  Union[str, Any]					):
													if name in self.keys() and value is not None:
																			# Don't call self.__setitem__ to avoid recursion errors
																			super().__setitem__(lowerCamelCase_		,			lowerCamelCase_					)
													super().__setattr__(lowerCamelCase_		,			lowerCamelCase_					)






							def __setitem__(    self			:  Union[str, Any]		,			lowerCamelCase_			:  Tuple		,			lowerCamelCase_			:  List[Any]					):
													# Will raise a KeyException if needed
													super().__setitem__(lowerCamelCase_		,			lowerCamelCase_					)
													# Don't call self.__setattr__ to avoid recursion errors
													super().__setattr__(lowerCamelCase_		,			lowerCamelCase_					)






							def        lowerCAmelCase  (    self			:  Any					):
													return tuple(self[k] for k in self.keys()					)



"""simple docstring"""







from __future__ import annotations






def        a__			(							_UpperCamelCase			):





						"""simple docstring"""

						UpperCAmelCase__												=     sorted(_UpperCamelCase			)
						UpperCAmelCase__												=     len(_UpperCamelCase			)
						UpperCAmelCase__												=     length >> 1
						return (
						    (sorted_list[mid_index] + sorted_list[mid_index - 1]) / 2
						    if length % 2 == 0
						    else sorted_list[mid_index]
						)






def        a__			(							):





						"""simple docstring"""

						import doctest

						doctest.testmod()


if __name__ == "__main__":
						main()