




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

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

			return isinstance(snake_case__ ,				np.ndarray						)




class  A		(			SCREAMING_SNAKE_CASE__		):




				'''simple docstring'''





				def 	a_	(self      )     ->	Dict:
							__UpperCamelCase				:      str									=       fields(self      )

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

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

							if other_fields_are_none and isinstance(_UpperCAmelCase			,  _UpperCAmelCase      ):
										for key, value in first_field.items():
													__UpperCamelCase				:      List[Any]									=       value
							else:
										for field in class_fields:
													__UpperCamelCase				:      Any									=       getattr(self			,  field.name      )
													if v is not None:
																__UpperCamelCase				:      Dict									=       v
				def __delitem__(self			,  *_UpperCAmelCase			,  **_UpperCAmelCase      )     ->	Union[str, Any]:
							raise Exception(f"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."      )
				def 	a_	(self			,  *_UpperCAmelCase			,  **_UpperCAmelCase      )     ->	Union[str, Any]:
							raise Exception(f"You cannot use ``setdefault`` on a {self.__class__.__name__} instance."      )
				def 	a_	(self			,  *_UpperCAmelCase			,  **_UpperCAmelCase      )     ->	Dict:
							raise Exception(f"You cannot use ``pop`` on a {self.__class__.__name__} instance."      )
				def 	a_	(self			,  *_UpperCAmelCase			,  **_UpperCAmelCase      )     ->	Optional[Any]:
							raise Exception(f"You cannot use ``update`` on a {self.__class__.__name__} instance."      )
				def __getitem__(self			,  _UpperCAmelCase      )     ->	str:
							if isinstance(_UpperCAmelCase			,  _UpperCAmelCase      ):
										__UpperCamelCase				:      str									=       dict(self.items()      )
										return inner_dict[k]
							else:
										return self.to_tuple()[k]
				def __setattr__(self			,  _UpperCAmelCase			,  _UpperCAmelCase      )     ->	Tuple:
							if name in self.keys() and value is not None:
										# Don't call self.__setitem__ to avoid recursion errors
										super().__setitem__(_UpperCAmelCase			,  _UpperCAmelCase      )
							super().__setattr__(_UpperCAmelCase			,  _UpperCAmelCase      )
				def __setitem__(self			,  _UpperCAmelCase			,  _UpperCAmelCase      )     ->	List[Any]:
							# Will raise a KeyException if needed
							super().__setitem__(_UpperCAmelCase			,  _UpperCAmelCase      )
							# Don't call self.__setattr__ to avoid recursion errors
							super().__setattr__(_UpperCAmelCase			,  _UpperCAmelCase      )





				def 	a_	(self      )     ->	Tuple[Any]:
							return tuple(self[k] for k in self.keys()      )









'''simple docstring'''






from doctest import testmod
from math import sqrt

def       __lowerCAmelCase (   snake_case__						):
			__UpperCamelCase				:      list[int]									=       []
			if num < 1:
						return facs
			facs.append(1						)
			if num == 1:
						return facs
			facs.append(snake_case__						)
			for i in range(2 ,				int(sqrt(snake_case__						)						) + 1						):
						if num % i == 0:  # If i is a factor of num
									facs.append(snake_case__						)
									__UpperCamelCase				:      List[str]									=       num // i  # num//i is the other factor of num
									if d != i:  # If d and i are distinct
												facs.append(snake_case__						)  # we have found another factor
			facs.sort()
			return facs


if __name__ == "__main__":
				testmod(name='''factors_of_a_number''', verbose=True)



