



# 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 tensorflow as tf







class      __lowerCAmelCase       (     TensorFormatter[Mapping, '''tf.Tensor''', Mapping]		):



			def __init__(		self  :    str					,						A  :    Dict=None					,						**A  :    Dict)  ->       List[str]:



						"""simple docstring"""






						super().__init__(features=A)
						_UpperCAmelCase									=  tf_tensor_kwargs
						import tensorflow as tf  # noqa: import tf at initialization



			def        _lowerCamelCase			(		self  :    str					,						A  :    Optional[int])  ->       Dict:



						"""simple docstring"""






						import tensorflow as tf

						if isinstance(A					,						A) and column:
									if all(
									    isinstance(A					,						tf.Tensor) and x.shape == column[0].shape and x.dtype == column[0].dtype for x in column):
												return tf.stack(A)
									elif all(
									    isinstance(A					,						(tf.Tensor, tf.RaggedTensor)) and x.ndim == 1 and x.dtype == column[0].dtype
									    for x in column):
												# only rag 1-D tensors, otherwise some dimensions become ragged even though they were consolidated
												return tf.ragged.stack(A)

						return column



			def        _lowerCamelCase			(		self  :    int					,						A  :    List[Any])  ->       int:



						"""simple docstring"""






						import tensorflow as tf

						if value is None:
									return value

						_UpperCAmelCase									=  {}

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

									if isinstance(A					,						PIL.Image.Image):
												_UpperCAmelCase									=  np.asarray(A)

						return tf.convert_to_tensor(A					,						**{**default_dtype, **self.tf_tensor_kwargs})



			def        _lowerCamelCase			(		self  :    int					,						A  :    int)  ->       int:



						"""simple docstring"""






						import tensorflow as tf

						# support for torch, tf, jax etc.
						if config.TORCH_AVAILABLE and "torch" in sys.modules:
									import torch

									if isinstance(A					,						torch.Tensor):
												return self._tensorize(data_struct.detach().cpu().numpy()[()])
						if hasattr(A					,						'__array__') and not isinstance(A					,						tf.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:  # tf 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        _lowerCamelCase			(		self  :    List[Any]					,						A  :    dict)  ->       Dict:



						"""simple docstring"""






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



			def        _lowerCamelCase			(		self  :    Optional[int]					,						A  :    pa.Table)  ->       Mapping:



						"""simple docstring"""






						_UpperCAmelCase									=  self.numpy_arrow_extractor().extract_row(A)
						_UpperCAmelCase									=  self.python_features_decoder.decode_row(A)
						return self.recursive_tensorize(A)



			def        _lowerCamelCase			(		self  :    int					,						A  :    pa.Table)  ->       "tf.Tensor":



						"""simple docstring"""






						_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        _lowerCamelCase			(		self  :    Optional[int]					,						A  :    pa.Table)  ->       Mapping:



						"""simple docstring"""






						_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





import math





def 				A      (	_UpperCAmelCase							:  int       )							->					int:







			'''simple docstring'''
			return sum(int(_UpperCAmelCase       ) for digit in str(_UpperCAmelCase       )       )





def 				A      (	_UpperCAmelCase							:  int = 30       )							->					int:







			'''simple docstring'''
			_UpperCAmelCase									=  []
			for digit in range(2				,  100       ):
						for power in range(2				,  100       ):
									_UpperCAmelCase									=  int(math.pow(_UpperCAmelCase				,  _UpperCAmelCase       )       )
									if digit == digit_sum(_UpperCAmelCase       ):
												digit_to_powers.append(_UpperCAmelCase       )

			digit_to_powers.sort()
			return digit_to_powers[n - 1]


if __name__ == "__main__":
							print(solution())
