





# 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]    ):
			'''simple docstring'''




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







					"""simple docstring"""






					super().__init__(features=__lowerCAmelCase   )
					A__        =   torch_tensor_kwargs
					import torch  # noqa import torch at initialization






			def    a_       (			self   :    List[str]							,	__lowerCAmelCase   :    Optional[Any]   )	->	Optional[Any]:







					"""simple docstring"""






					import torch

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






			def    a_       (			self   :    List[Any]							,	__lowerCAmelCase   :    int   )	->	Dict:







					"""simple docstring"""






					import torch

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

					A__        =   {}

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

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






			def    a_       (			self   :    Optional[Any]							,	__lowerCAmelCase   :    Dict   )	->	Union[str, Any]:







					"""simple docstring"""






					import torch

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






			def    a_       (			self   :    Tuple							,	__lowerCAmelCase   :    dict   )	->	Any:







					"""simple docstring"""






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






			def    a_       (			self   :    Union[str, Any]							,	__lowerCAmelCase   :    pa.Table   )	->	Mapping:







					"""simple docstring"""






					A__        =   self.numpy_arrow_extractor().extract_row(__lowerCAmelCase   )
					A__        =   self.python_features_decoder.decode_row(__lowerCAmelCase   )
					return self.recursive_tensorize(__lowerCAmelCase   )






			def    a_       (			self   :    Union[str, Any]							,	__lowerCAmelCase   :    pa.Table   )	->	"torch.Tensor":







					"""simple docstring"""






					A__        =   self.numpy_arrow_extractor().extract_column(__lowerCAmelCase   )
					A__        =   self.python_features_decoder.decode_column(__lowerCAmelCase							,	pa_table.column_names[0]   )
					A__        =   self.recursive_tensorize(__lowerCAmelCase   )
					A__        =   self._consolidate(__lowerCAmelCase   )
					return column







			def    a_       (			self   :    Dict							,	__lowerCAmelCase   :    pa.Table   )	->	Mapping:







					"""simple docstring"""






					A__        =   self.numpy_arrow_extractor().extract_batch(__lowerCAmelCase   )
					A__        =   self.python_features_decoder.decode_batch(__lowerCAmelCase   )
					A__        =   self.recursive_tensorize(__lowerCAmelCase   )
					for column_name in batch:
							A__        =   self._consolidate(batch[column_name]   )
					return batch










def    __lowerCamelCase					(							__a   :int = 1_0_0_0_0_0_0    )		->				int:






		"""simple docstring"""

		A__        =   limit + 1
		A__        =   [0] * limit
		for first_term in range(1    ,     __a    ):
				for n in range(__a    ,     __a    ,     __a    ):
						A__        =   first_term + n / first_term
						if common_difference % 4:  # d must be divisble by 4
								continue
						else:
								common_difference /= 4
								if (
								    first_term > common_difference
								    and first_term < 4 * common_difference
								):  # since x,y,z are positive integers
										frequency[n] += 1  # so z>0 and a>d ,also 4d<a

		A__        =   sum(1 for x in frequency[1:limit] if x == 1_0    )

		return count


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



