


"""simple docstring"""







import collections
import gzip
import os
import urllib

import numpy
from tensorflow.python.framework import dtypes, random_seed
from tensorflow.python.platform import gfile
from tensorflow.python.util.deprecation import deprecated

lowerCAmelCase__      				=   collections.namedtuple('''_Datasets''', ['''train''', '''validation''', '''test'''])

# CVDF mirror of http://yann.lecun.com/exdb/mnist/
lowerCAmelCase__      				=   "https://storage.googleapis.com/cvdf-datasets/mnist/"
def 					a__			(				SCREAMING_SNAKE_CASE    :    Optional[Any]				):


  '''simple docstring'''







  lowerCAmelCase     :     str								=							numpy.dtype(numpy.uintaa				).newbyteorder(">"				)
  return numpy.frombuffer(bytestream.read(4				)				,      dtype=__A				)[0]
@deprecated(__A				,      "Please use tf.data to implement this functionality."				)
def 					a__			(				SCREAMING_SNAKE_CASE    :    List[Any]				):


  '''simple docstring'''







  print("Extracting"				,      f.name				)
  with gzip.GzipFile(fileobj=__A				) as bytestream:
    lowerCAmelCase     :     Dict								=							_readaa(__A				)
    if magic != 2_0_5_1:
      raise ValueError(
          "Invalid magic number %d in MNIST image file: %s" % (magic, f.name)				)
    lowerCAmelCase     :     Optional[Any]								=							_readaa(__A				)
    lowerCAmelCase     :     Optional[int]								=							_readaa(__A				)
    lowerCAmelCase     :     Tuple								=							_readaa(__A				)
    lowerCAmelCase     :     int								=							bytestream.read(rows * cols * num_images				)
    lowerCAmelCase     :     Union[str, Any]								=							numpy.frombuffer(__A				,      dtype=numpy.uinta				)
    lowerCAmelCase     :     Any								=							data.reshape(__A				,      __A				,      __A				,      1				)
    return data
@deprecated(__A				,      "Please use tf.one_hot on tensors."				)
def 					a__			(				SCREAMING_SNAKE_CASE    :    List[Any]				,      SCREAMING_SNAKE_CASE    :    Any				):


  '''simple docstring'''







  lowerCAmelCase     :     Optional[int]								=							labels_dense.shape[0]
  lowerCAmelCase     :     Tuple								=							numpy.arange(__A				) * num_classes
  lowerCAmelCase     :     int								=							numpy.zeros((num_labels, num_classes)				)
  lowerCAmelCase     :     Optional[Any]								=							1
  return labels_one_hot
@deprecated(__A				,      "Please use tf.data to implement this functionality."				)
def 					a__			(				SCREAMING_SNAKE_CASE    :    int				,      SCREAMING_SNAKE_CASE    :    Any=False				,      SCREAMING_SNAKE_CASE    :    Union[str, Any]=1_0				):


  '''simple docstring'''







  print("Extracting"				,      f.name				)
  with gzip.GzipFile(fileobj=__A				) as bytestream:
    lowerCAmelCase     :     List[str]								=							_readaa(__A				)
    if magic != 2_0_4_9:
      raise ValueError(
          "Invalid magic number %d in MNIST label file: %s" % (magic, f.name)				)
    lowerCAmelCase     :     Optional[Any]								=							_readaa(__A				)
    lowerCAmelCase     :     Any								=							bytestream.read(__A				)
    lowerCAmelCase     :     Dict								=							numpy.frombuffer(__A				,      dtype=numpy.uinta				)
    if one_hot:
      return _dense_to_one_hot(__A				,      __A				)
    return labels


class       SCREAMING_SNAKE_CASE__				:
       """simple docstring"""


       @deprecated(
           lowerCAmelCase_		,     "Please use alternatives such as official/mnist/_DataSet.py"
           " from tensorflow/models."		,     )
       def __init__(						self		,     snake_case__		,     snake_case__		,     snake_case__=False		,     snake_case__=False		,     snake_case__=dtypes.floataa		,     snake_case__=True		,     snake_case__=None		,     ):






         """simple docstring"""





         lowerCAmelCase						,  lowerCAmelCase     :     Any								=							random_seed.get_seed(lowerCAmelCase_						)
         # If op level seed is not set, use whatever graph level seed is returned
         numpy.random.seed(seeda if seed is None else seeda						)
         lowerCAmelCase     :     Dict								=							dtypes.as_dtype(lowerCAmelCase_						).base_dtype
         if dtype not in (dtypes.uinta, dtypes.floataa):
           raise TypeError("Invalid image dtype %r, expected uint8 or float32" % dtype						)
         if fake_data:
           lowerCAmelCase     :     List[Any]								=							10_000
           lowerCAmelCase     :     List[Any]								=							one_hot
         else:
           assert (
               images.shape[0] == labels.shape[0]
           ), f"""images.shape: {images.shape} labels.shape: {labels.shape}"""
           lowerCAmelCase     :     Dict								=							images.shape[0]

           # Convert shape from [num examples, rows, columns, depth]
           # to [num examples, rows*columns] (assuming depth == 1)
           if reshape:
             assert images.shape[3] == 1
             lowerCAmelCase     :     Optional[int]								=							images.reshape(
                 images.shape[0]		,     images.shape[1] * images.shape[2]						)
           if dtype == dtypes.floataa:
             # Convert from [0, 255] -> [0.0, 1.0].
             lowerCAmelCase     :     Any								=							images.astype(numpy.floataa						)
             lowerCAmelCase     :     str								=							numpy.multiply(lowerCAmelCase_		,     1.0 / 255.0						)
         lowerCAmelCase     :     Tuple								=							images
         lowerCAmelCase     :     List[str]								=							labels
         lowerCAmelCase     :     Tuple								=							0
         lowerCAmelCase     :     Dict								=							0

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return self._images

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return self._labels

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return self._num_examples

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return self._epochs_completed







       def        lowercase__							(						self		,     snake_case__		,     snake_case__=False		,     snake_case__=True						):






         """simple docstring"""





         if fake_data:
           lowerCAmelCase     :     Any								=							[1] * 784
           lowerCAmelCase     :     int								=							[1] + [0] * 9 if self.one_hot else 0
           return (
               [fake_image for _ in range(lowerCAmelCase_						)],
               [fake_label for _ in range(lowerCAmelCase_						)],
           )
         lowerCAmelCase     :     Tuple								=							self._index_in_epoch
         # Shuffle for the first epoch
         if self._epochs_completed == 0 and start == 0 and shuffle:
           lowerCAmelCase     :     Optional[Any]								=							numpy.arange(self._num_examples						)
           numpy.random.shuffle(lowerCAmelCase_						)
           lowerCAmelCase     :     str								=							self.images[perma]
           lowerCAmelCase     :     List[str]								=							self.labels[perma]
         # Go to the next epoch
         if start + batch_size > self._num_examples:
           # Finished epoch
           self._epochs_completed += 1
           # Get the rest examples in this epoch
           lowerCAmelCase     :     Union[str, Any]								=							self._num_examples - start
           lowerCAmelCase     :     Union[str, Any]								=							self._images[start : self._num_examples]
           lowerCAmelCase     :     Dict								=							self._labels[start : self._num_examples]
           # Shuffle the data
           if shuffle:
             lowerCAmelCase     :     Union[str, Any]								=							numpy.arange(self._num_examples						)
             numpy.random.shuffle(lowerCAmelCase_						)
             lowerCAmelCase     :     int								=							self.images[perm]
             lowerCAmelCase     :     List[str]								=							self.labels[perm]
           # Start next epoch
           lowerCAmelCase     :     Optional[int]								=							0
           lowerCAmelCase     :     Optional[Any]								=							batch_size - rest_num_examples
           lowerCAmelCase     :     Tuple								=							self._index_in_epoch
           lowerCAmelCase     :     Dict								=							self._images[start:end]
           lowerCAmelCase     :     List[str]								=							self._labels[start:end]
           return (
               numpy.concatenate((images_rest_part, images_new_part)		,     axis=0						),
               numpy.concatenate((labels_rest_part, labels_new_part)		,     axis=0						),
           )
         else:
           self._index_in_epoch += batch_size
           lowerCAmelCase     :     Optional[int]								=							self._index_in_epoch
           return self._images[start:end], self._labels[start:end]

@deprecated(__A				,      "Please write your own downloading logic."				)
def 					a__			(				SCREAMING_SNAKE_CASE    :    Tuple				,      SCREAMING_SNAKE_CASE    :    Dict				,      SCREAMING_SNAKE_CASE    :    int				):


  '''simple docstring'''







  if not gfile.Exists(__A				):
    gfile.MakeDirs(__A				)
  lowerCAmelCase     :     Union[str, Any]								=							os.path.join(__A				,      __A				)
  if not gfile.Exists(__A				):
    urllib.request.urlretrieve(__A				,      __A				)  # noqa: S310
    with gfile.GFile(__A				) as f:
      lowerCAmelCase     :     Tuple								=							f.size()
    print("Successfully downloaded"				,      __A				,      __A				,      "bytes."				)
  return filepath





@deprecated(
    __A				,      "Please use alternatives such as:" " tensorflow_datasets.load(\'mnist\')"				)
def 					a__			(				SCREAMING_SNAKE_CASE    :    List[str]				,      SCREAMING_SNAKE_CASE    :    Dict=False				,      SCREAMING_SNAKE_CASE    :    Tuple=False				,      SCREAMING_SNAKE_CASE    :    Any=dtypes.floataa				,      SCREAMING_SNAKE_CASE    :    Any=True				,      SCREAMING_SNAKE_CASE    :    str=5_0_0_0				,      SCREAMING_SNAKE_CASE    :    Union[str, Any]=None				,      SCREAMING_SNAKE_CASE    :    List[str]=DEFAULT_SOURCE_URL				,      ):


  '''simple docstring'''







  if fake_data:

    def fake():
      return _DataSet(
          []				,      []				,      fake_data=__A				,      one_hot=__A				,      dtype=__A				,      seed=__A				)

    lowerCAmelCase     :     Tuple								=							fake()
    lowerCAmelCase     :     Optional[Any]								=							fake()
    lowerCAmelCase     :     Any								=							fake()
    return _Datasets(train=__A				,      validation=__A				,      test=__A				)

  if not source_url:  # empty string check
    lowerCAmelCase     :     List[Any]								=							DEFAULT_SOURCE_URL

  lowerCAmelCase     :     Optional[Any]								=							"train-images-idx3-ubyte.gz"
  lowerCAmelCase     :     Union[str, Any]								=							"train-labels-idx1-ubyte.gz"
  lowerCAmelCase     :     List[str]								=							"t10k-images-idx3-ubyte.gz"
  lowerCAmelCase     :     Optional[int]								=							"t10k-labels-idx1-ubyte.gz"

  lowerCAmelCase     :     str								=							_maybe_download(
      __A				,      __A				,      source_url + train_images_file				)
  with gfile.Open(__A				,      "rb"				) as f:
    lowerCAmelCase     :     Tuple								=							_extract_images(__A				)

  lowerCAmelCase     :     Optional[Any]								=							_maybe_download(
      __A				,      __A				,      source_url + train_labels_file				)
  with gfile.Open(__A				,      "rb"				) as f:
    lowerCAmelCase     :     Union[str, Any]								=							_extract_labels(__A				,      one_hot=__A				)

  lowerCAmelCase     :     Optional[int]								=							_maybe_download(
      __A				,      __A				,      source_url + test_images_file				)
  with gfile.Open(__A				,      "rb"				) as f:
    lowerCAmelCase     :     Dict								=							_extract_images(__A				)

  lowerCAmelCase     :     Any								=							_maybe_download(
      __A				,      __A				,      source_url + test_labels_file				)
  with gfile.Open(__A				,      "rb"				) as f:
    lowerCAmelCase     :     int								=							_extract_labels(__A				,      one_hot=__A				)

  if not 0 <= validation_size <= len(__A				):
    lowerCAmelCase     :     List[str]								=							(
        "Validation size should be between 0 and "
        f"""{len(__A				)}. Received: {validation_size}."""
    )
    raise ValueError(__A				)

  lowerCAmelCase     :     str								=							train_images[:validation_size]
  lowerCAmelCase     :     Union[str, Any]								=							train_labels[:validation_size]
  lowerCAmelCase     :     Any								=							train_images[validation_size:]
  lowerCAmelCase     :     Optional[int]								=							train_labels[validation_size:]

  lowerCAmelCase     :     str								=							{"dtype": dtype, "reshape": reshape, "seed": seed}

  lowerCAmelCase     :     str								=							_DataSet(__A				,      __A				,      **__A				)
  lowerCAmelCase     :     int								=							_DataSet(__A				,      __A				,      **__A				)
  lowerCAmelCase     :     int								=							_DataSet(__A				,      __A				,      **__A				)

  return _Datasets(train=__A				,      validation=__A				,      test=__A				)







'''simple docstring'''







def 				SCREAMING_SNAKE_CASE__	(   __A	)       ->	str:
	_snake_case   						=		1
	_snake_case   						=		2
	while i * i <= n:
		_snake_case   						=		0
		while n % i == 0:
			n //= i
			multiplicity += 1
		n_divisors *= multiplicity + 1
		i += 1
	if n > 1:
		n_divisors *= 2
	return n_divisors







def 				SCREAMING_SNAKE_CASE__	(   )       ->	List[str]:
	_snake_case   						=		1
	_snake_case   						=		1

	while True:
		i += 1
		t_num += i

		if count_divisors(__A	) > 500:
			break

	return t_num


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

