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

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

						return isinstance(lowercase__						,						np.ndarray		)







class      A							(    __UpperCAmelCase			):



			def A__	(   self    )     ->						List[Any]:




									'''simple docstring'''



									lowercase__								=    fields(self    )

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

									lowercase__								=    getattr(self    ,       class_fields[0].name    )
									lowercase__								=    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():
																					lowercase__								=    value
									else:
															for field in class_fields:
																					lowercase__								=    getattr(self    ,       field.name    )
																					if v is not None:
																											lowercase__								=    v



			def __delitem__(   self    ,       *lowerCamelCase__    ,       **lowerCamelCase__    )     ->						int:




									'''simple docstring'''



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



			def A__	(   self    ,       *lowerCamelCase__    ,       **lowerCamelCase__    )     ->						int:




									'''simple docstring'''



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



			def A__	(   self    ,       *lowerCamelCase__    ,       **lowerCamelCase__    )     ->						Optional[int]:




									'''simple docstring'''



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



			def A__	(   self    ,       *lowerCamelCase__    ,       **lowerCamelCase__    )     ->						Optional[int]:




									'''simple docstring'''



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



			def __getitem__(   self    ,       lowerCamelCase__    )     ->						int:




									'''simple docstring'''



									if isinstance(lowerCamelCase__    ,       lowerCamelCase__    ):
															lowercase__								=    dict(self.items()    )
															return inner_dict[k]
									else:
															return self.to_tuple()[k]



			def __setattr__(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    )     ->						Optional[int]:




									'''simple docstring'''



									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    ,       lowerCamelCase__    ,       lowerCamelCase__    )     ->						str:




									'''simple docstring'''



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



			def A__	(   self    )     ->						Tuple[Any]:




									'''simple docstring'''



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








'''simple docstring'''



def 	_A						(							lowercase__		):
						if not isinstance(lowercase__						,						lowercase__		):
												raise ValueError("""Input series is not valid, valid series - [1, 2/3, 2]"""		)
						if len(lowercase__		) == 0:
												raise ValueError("""Input list must be a non empty list"""		)
						if len(lowercase__		) == 1 and series[0] != 0:
												return True
						lowercase__								=    []
						lowercase__								=    len(lowercase__		)
						for i in range(0						,						lowercase__		):
												if series[i] == 0:
																		raise ValueError("""Input series cannot have 0 as an element"""		)
												rec_series.append(1 / series[i]		)
						lowercase__								=    rec_series[1] - rec_series[0]
						for index in range(2						,						lowercase__		):
												if rec_series[index] - rec_series[index - 1] != common_diff:
																		return False
						return True





def 	_A						(							lowercase__		):
						if not isinstance(lowercase__						,						lowercase__		):
												raise ValueError("""Input series is not valid, valid series - [2, 4, 6]"""		)
						if len(lowercase__		) == 0:
												raise ValueError("""Input list must be a non empty list"""		)
						lowercase__								=    0
						for val in series:
												answer += 1 / val
						return len(lowercase__		) / answer


if __name__ == "__main__":
				import doctest

				doctest.testmod()






