'''simple docstring'''





# Lint as: python3
import sys
from collections.abc import Mapping
from typing import TYPE_CHECKING

import numpy as np
import pyarrow as pa

from .. import config
from ..utils.py_utils import map_nested
from .formatting import TensorFormatter


if TYPE_CHECKING:
    import torch




class        __A      ( TensorFormatter[Mapping, """torch.Tensor""", Mapping]	):



    def __init__(self    :    Union[str, Any]   ,			__a    :    Tuple=None   ,			**__a    :    List[Any] ):
         super().__init__(features=__a )
         UpperCAmelCase_           =   torch_tensor_kwargs
         import torch  # noqa import torch at initialization



    def 					_lowercase						(self    :    Optional[Any]   ,			__a    :    int ):
         import torch

         if isinstance(__a   ,			__a ) and column:
              if all(
                  isinstance(__a   ,			torch.Tensor ) and x.shape == column[0].shape and x.dtype == column[0].dtype
                  for x in column ):
                   return torch.stack(__a )
         return column



    def 					_lowercase						(self    :    Optional[Any]   ,			__a    :    Tuple ):
         import torch

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

         UpperCAmelCase_           =   {}

         if isinstance(__a   ,			(np.number, np.ndarray) ) and np.issubdtype(value.dtype   ,			np.integer ):
              UpperCAmelCase_           =   {"dtype": torch.intaa}
         elif isinstance(__a   ,			(np.number, np.ndarray) ) and np.issubdtype(value.dtype   ,			np.floating ):
              UpperCAmelCase_           =   {"dtype": torch.floataa}
         elif config.PIL_AVAILABLE and "PIL" in sys.modules:
              import PIL.Image

              if isinstance(__a   ,			PIL.Image.Image ):
                   UpperCAmelCase_           =   np.asarray(__a )
         return torch.tensor(__a   ,			**{**default_dtype, **self.torch_tensor_kwargs} )



    def 					_lowercase						(self    :    int   ,			__a    :    str ):
         import torch

         # support for torch, tf, jax etc.
         if hasattr(__a   ,			"__array__" ) and not isinstance(__a   ,			torch.Tensor ):
              UpperCAmelCase_           =   data_struct.__array__()
         # support for nested types like struct of list of struct
         if isinstance(__a   ,			np.ndarray ):
              if data_struct.dtype == object:  # torch tensors cannot be instantied from an array of objects
                   return self._consolidate([self.recursive_tensorize(__a ) for substruct in data_struct] )
         elif isinstance(__a   ,			(list, tuple) ):
              return self._consolidate([self.recursive_tensorize(__a ) for substruct in data_struct] )
         return self._tensorize(__a )



    def 					_lowercase						(self    :    Any   ,			__a    :    dict ):
         return map_nested(self._recursive_tensorize   ,			__a   ,			map_list=__a )



    def 					_lowercase						(self    :    int   ,			__a    :    pa.Table ):
         UpperCAmelCase_           =   self.numpy_arrow_extractor().extract_row(__a )
         UpperCAmelCase_           =   self.python_features_decoder.decode_row(__a )
         return self.recursive_tensorize(__a )



    def 					_lowercase						(self    :    Union[str, Any]   ,			__a    :    pa.Table ):
         UpperCAmelCase_           =   self.numpy_arrow_extractor().extract_column(__a )
         UpperCAmelCase_           =   self.python_features_decoder.decode_column(__a   ,			pa_table.column_names[0] )
         UpperCAmelCase_           =   self.recursive_tensorize(__a )
         UpperCAmelCase_           =   self._consolidate(__a )
         return column






    def 					_lowercase						(self    :    Tuple   ,			__a    :    pa.Table ):
         UpperCAmelCase_           =   self.numpy_arrow_extractor().extract_batch(__a )
         UpperCAmelCase_           =   self.python_features_decoder.decode_batch(__a )
         UpperCAmelCase_           =   self.recursive_tensorize(__a )
         for column_name in batch:
              UpperCAmelCase_           =   self._consolidate(batch[column_name] )
         return batch









'''simple docstring'''

import math



def      __lowerCamelCase     (      lowerCAmelCase_  )			->      bool:
		_a     :      Optional[int]        =							math.loga(math.sqrt(4 * positive_integer + 1  ) / 2 + 1 / 2  )

		return exponent == int(lowerCAmelCase_  )



def      __lowerCamelCase     (      lowerCAmelCase_ = 1 / 12345  )			->      int:
		_a     :      int        =							0
		_a     :      Optional[Any]        =							0

		_a     :      int        =							3
		while True:
				_a     :      Tuple        =							(integer**2 - 1) / 4
				# if candidate is an integer, then there is a partition for k
				if partition_candidate == int(lowerCAmelCase_  ):
						_a     :      Union[str, Any]        =							int(lowerCAmelCase_  )
						total_partitions += 1
						if check_partition_perfect(lowerCAmelCase_  ):
								perfect_partitions += 1
				if perfect_partitions > 0:
						if perfect_partitions / total_partitions < max_proportion:
								return int(lowerCAmelCase_  )
				integer += 1


if __name__ == "__main__":
							print(f"""{solution() = }""")




