

import sys
from collections.abc import Mapping

import numpy as np
import pyarrow as pa

from .. import config
from ..utils.py_utils import map_nested
from .formatting import TensorFormatter
class 	_A						(					TensorFormatter[Mapping, np.ndarray, Mapping]):

  def __init__(			self	,   _SCREAMING_SNAKE_CASE=None	,   **_SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        super().__init__(features=_SCREAMING_SNAKE_CASE   )
        SCREAMING_SNAKE_CASE_			:					Optional[int]          =       np_array_kwargs

  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        if isinstance(_SCREAMING_SNAKE_CASE	,   _SCREAMING_SNAKE_CASE   ):
              if column and all(
                  isinstance(_SCREAMING_SNAKE_CASE	,   np.ndarray   ) and x.shape == column[0].shape and x.dtype == column[0].dtype for x in column   ):
                    return np.stack(_SCREAMING_SNAKE_CASE   )
              else:
                    # don't use np.array(column, dtype=object)
                    # since it fails in certain cases
                    # see https://stackoverflow.com/q/51005699
                    SCREAMING_SNAKE_CASE_			:					str          =       np.empty(len(_SCREAMING_SNAKE_CASE   )	,   dtype=_SCREAMING_SNAKE_CASE   )
                    SCREAMING_SNAKE_CASE_			:					str          =       column
                    return out
        return column

  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        if isinstance(_SCREAMING_SNAKE_CASE	,   (str, bytes, type(_SCREAMING_SNAKE_CASE   ))   ):
              return value
        elif isinstance(_SCREAMING_SNAKE_CASE	,   (np.character, np.ndarray)   ) and np.issubdtype(value.dtype	,   np.character   ):
              return value
        elif isinstance(_SCREAMING_SNAKE_CASE	,   np.number   ):
              return value

        SCREAMING_SNAKE_CASE_			:					List[Any]          =       {}

        if isinstance(_SCREAMING_SNAKE_CASE	,   np.ndarray   ) and np.issubdtype(value.dtype	,   np.integer   ):
              SCREAMING_SNAKE_CASE_			:					Optional[int]          =       {'dtype': np.intaa}
        elif isinstance(_SCREAMING_SNAKE_CASE	,   np.ndarray   ) and np.issubdtype(value.dtype	,   np.floating   ):
              SCREAMING_SNAKE_CASE_			:					Union[str, Any]          =       {'dtype': np.floataa}
        elif config.PIL_AVAILABLE and "PIL" in sys.modules:
              import PIL.Image

              if isinstance(_SCREAMING_SNAKE_CASE	,   PIL.Image.Image   ):
                    return np.asarray(_SCREAMING_SNAKE_CASE	,   **self.np_array_kwargs   )

        return np.asarray(_SCREAMING_SNAKE_CASE	,   **{**default_dtype, **self.np_array_kwargs}   )

  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        if config.TORCH_AVAILABLE and "torch" in sys.modules:
              import torch

              if isinstance(_SCREAMING_SNAKE_CASE	,   torch.Tensor   ):
                    return self._tensorize(data_struct.detach().cpu().numpy()[()]   )
        if hasattr(_SCREAMING_SNAKE_CASE	,   '__array__'   ) and not isinstance(_SCREAMING_SNAKE_CASE	,   (np.ndarray, np.character, np.number)   ):
              SCREAMING_SNAKE_CASE_			:					List[str]          =       data_struct.__array__()
        # support for nested types like struct of list of struct
        if isinstance(_SCREAMING_SNAKE_CASE	,   np.ndarray   ):
              if data_struct.dtype == object:
                    return self._consolidate([self.recursive_tensorize(_SCREAMING_SNAKE_CASE   ) for substruct in data_struct]   )
        if isinstance(_SCREAMING_SNAKE_CASE	,   (list, tuple)   ):
              return self._consolidate([self.recursive_tensorize(_SCREAMING_SNAKE_CASE   ) for substruct in data_struct]   )
        return self._tensorize(_SCREAMING_SNAKE_CASE   )

  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        return map_nested(self._recursive_tensorize	,   _SCREAMING_SNAKE_CASE	,   map_list=_SCREAMING_SNAKE_CASE   )

  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Dict          =       self.numpy_arrow_extractor().extract_row(_SCREAMING_SNAKE_CASE   )
        SCREAMING_SNAKE_CASE_			:					Optional[int]          =       self.python_features_decoder.decode_row(_SCREAMING_SNAKE_CASE   )
        return self.recursive_tensorize(_SCREAMING_SNAKE_CASE   )

  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					List[Any]          =       self.numpy_arrow_extractor().extract_column(_SCREAMING_SNAKE_CASE   )
        SCREAMING_SNAKE_CASE_			:					int          =       self.python_features_decoder.decode_column(_SCREAMING_SNAKE_CASE	,   pa_table.column_names[0]   )
        SCREAMING_SNAKE_CASE_			:					Union[str, Any]          =       self.recursive_tensorize(_SCREAMING_SNAKE_CASE   )
        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       self._consolidate(_SCREAMING_SNAKE_CASE   )
        return column



  def 	UpperCAmelCase      (			self	,   _SCREAMING_SNAKE_CASE   ):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_			:					Tuple          =       self.numpy_arrow_extractor().extract_batch(_SCREAMING_SNAKE_CASE   )
        SCREAMING_SNAKE_CASE_			:					Tuple          =       self.python_features_decoder.decode_batch(_SCREAMING_SNAKE_CASE   )
        SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       self.recursive_tensorize(_SCREAMING_SNAKE_CASE   )
        for column_name in batch:
              SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       self._consolidate(batch[column_name]   )
        return batch









from math import sqrt

def 				A_					(							a					):

      """simple docstring"""



      SCREAMING_SNAKE_CASE_			:					List[str]          =       [1]
      for i in range(2   ,				int(sqrt(a					)					) + 1   ,				1					):
            if number % i == 0:
                  values.append(a					)
                  if int(number // i					) != i:
                        values.append(int(number // i					)					)
      return sorted(a					)

def 				A_					(							a					):

      """simple docstring"""



      return sum(factors(a					)					) > n

def 				A_					(							a					):

      """simple docstring"""



      SCREAMING_SNAKE_CASE_			:					Union[str, Any]          =       factors(a					)
      SCREAMING_SNAKE_CASE_			:					Optional[int]          =       len(a					)
      SCREAMING_SNAKE_CASE_			:					Optional[int]          =       [[0 for i in range(number + 1					)] for j in range(r + 1					)]
      for i in range(r + 1					):
            SCREAMING_SNAKE_CASE_			:					Optional[int]          =       True

      for i in range(1   ,				number + 1					):
            SCREAMING_SNAKE_CASE_			:					Optional[Any]          =       False

      for i in range(1   ,				r + 1					):
            for j in range(1   ,				number + 1					):
                  if j < values[i - 1]:
                        SCREAMING_SNAKE_CASE_			:					Dict          =       subset[i - 1][j]
                  else:
                        SCREAMING_SNAKE_CASE_			:					List[str]          =       subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

      return subset[r][number] != 0

def 				A_					(							a					):

      """simple docstring"""



      return abundant(a					) and not semi_perfect(a					)


if __name__ == "__main__":
    import doctest

    doctest.testmod(verbose=True)
    for number in (69, 70, 71):
        print(F'{number} is {"" if weird(number) else "not "}weird.')






