




"""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 					UpperCamelCase__       (						lowercase__					:       Tuple				):
		if is_torch_available():
				import torch

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

		return isinstance(lowercase__    ,       np.ndarray				)
class      lowerCamelCase__      (					lowerCamelCase_     ):


			def 							lowerCamelCase_			(       self							):



					"""simple docstring"""







					snake_case						:  Optional[Any]        =			fields(self							)

					# Safety and consistency checks
					if not len(SCREAMING_SNAKE_CASE							):
							raise ValueError(F'''{self.__class__.__name__} has no fields.'''							)

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

					if other_fields_are_none and isinstance(SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							):
							for key, value in first_field.items():
									snake_case						:  Dict        =			value
					else:
							for field in class_fields:
									snake_case						:  Union[str, Any]        =			getattr(self			,	field.name							)
									if v is not None:
											snake_case						:  str        =			v


			def __delitem__(       self			,	*SCREAMING_SNAKE_CASE			,	**SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					raise Exception(F'''You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.'''							)


			def 							lowerCamelCase_			(       self			,	*SCREAMING_SNAKE_CASE			,	**SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					raise Exception(F'''You cannot use ``setdefault`` on a {self.__class__.__name__} instance.'''							)


			def 							lowerCamelCase_			(       self			,	*SCREAMING_SNAKE_CASE			,	**SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					raise Exception(F'''You cannot use ``pop`` on a {self.__class__.__name__} instance.'''							)


			def 							lowerCamelCase_			(       self			,	*SCREAMING_SNAKE_CASE			,	**SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					raise Exception(F'''You cannot use ``update`` on a {self.__class__.__name__} instance.'''							)


			def __getitem__(       self			,	SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					if isinstance(SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							):
							snake_case						:  Optional[int]        =			dict(self.items()							)
							return inner_dict[k]
					else:
							return self.to_tuple()[k]


			def __setattr__(       self			,	SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					if name in self.keys() and value is not None:
							# Don't call self.__setitem__ to avoid recursion errors
							super().__setitem__(SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							)
					super().__setattr__(SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							)


			def __setitem__(       self			,	SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					super().__setitem__(SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							)
					# Don't call self.__setattr__ to avoid recursion errors
					super().__setattr__(SCREAMING_SNAKE_CASE			,	SCREAMING_SNAKE_CASE							)



			def 							lowerCamelCase_			(       self							):



					"""simple docstring"""







					return tuple(self[k] for k in self.keys()							)







"""simple docstring"""

def 					UpperCamelCase__       (						lowercase__					:       set    ,       lowercase__					:       set				):
		assert isinstance(lowercase__    ,       lowercase__				), F'''The input value of [set_a={set_a}] is not a set'''
		assert isinstance(lowercase__    ,       lowercase__				), F'''The input value of [set_b={set_b}] is not a set'''

		return {a + b for a in set_a for b in set_b}


if __name__ == "__main__":
							from doctest import testmod

							testmod()

