original_docstring: Load mnist dataset, return images and labels,
              if  dataset doesn't exist, then download it to directory that out_dir specified
  
      Args:
          train_batch_size (int, optional): batch size for train. Defaults to 100.
          test_batch_size (int, optional): batch size for test or evaluate. Defaults to 100.
          data_format (str, optional): data format. Defaults to "NCHW".
          url (str, optional): url to get mnist.npz. Defaults to "https://oneflow-public.oss-cn-beijing.aliyuncs.com/datasets/mnist.npz".
          hash_check (str, optional): file hash value. Defaults to "63d4344077849053dc3036b247fa012b2b381de53fd055a66b539dffd76cf08e".
          out_dir (str, optional): dir to save downloaded file. Defaults to "./".
  
      Returns:
          (train_images, train_labels), (test_images, test_labels)
      
docstring: Load mnist dataset, return images and labels,
  if  dataset doesn't exist, then download it to directory that out_dir specified
docstring_tokens: Load mnist dataset return images and labels if dataset doesn ' t exist then download it to directory that out_dir specified
code: def load_mnist(
      train_batch_size=100,
      test_batch_size=100,
      data_format="NCHW",
      url="https://oneflow-public.oss-cn-beijing.aliyuncs.com/datasets/mnist.npz",
      hash_check="63d4344077849053dc3036b247fa012b2b381de53fd055a66b539dffd76cf08e",
      out_dir=".",
  ):
      """Load mnist dataset, return images and labels,
              if  dataset doesn't exist, then download it to directory that out_dir specified
  
      Args:
          train_batch_size (int, optional): batch size for train. Defaults to 100.
          test_batch_size (int, optional): batch size for test or evaluate. Defaults to 100.
          data_format (str, optional): data format. Defaults to "NCHW".
          url (str, optional): url to get mnist.npz. Defaults to "https://oneflow-public.oss-cn-beijing.aliyuncs.com/datasets/mnist.npz".
          hash_check (str, optional): file hash value. Defaults to "63d4344077849053dc3036b247fa012b2b381de53fd055a66b539dffd76cf08e".
          out_dir (str, optional): dir to save downloaded file. Defaults to "./".
  
      Returns:
          (train_images, train_labels), (test_images, test_labels)
      """
      path = get_mnist_file(hash_check, url, out_dir)
      with np.load(path, allow_pickle=True) as f:
          (x_train, y_train) = (f["x_train"], f["y_train"])
          (x_test, y_test) = (f["x_test"], f["y_test"])
  
      def normalize(x, y, batch_size):
          x = x.astype(np.float32) / 255.0
          y = y.astype(np.int32)
          if data_format == "NCHW":
              images = x.reshape((-1, batch_size, 1, x.shape[1], x.shape[2]))
          else:
              images = x.reshape((-1, batch_size, x.shape[1], x.shape[2], 1))
          labels = y.reshape((-1, batch_size))
          return (images, labels)
  
      (train_images, train_labels) = normalize(x_train, y_train, train_batch_size)
      (test_images, test_labels) = normalize(x_test, y_test, test_batch_size)
      return ((train_images, train_labels), (test_images, test_labels))
code_tokens: def load_mnist ( train_batch_size = 100 , test_batch_size = 100 , data_format = "NCHW" , url = "https://oneflow-public.oss-cn-beijing.aliyuncs.com/datasets/mnist.npz" , hash_check = "63d4344077849053dc3036b247fa012b2b381de53fd055a66b539dffd76cf08e" , out_dir = "." , ) : path = get_mnist_file ( hash_check , url , out_dir ) with np . load ( path , allow_pickle = True ) as f : ( x_train , y_train ) = ( f [ "x_train" ] , f [ "y_train" ] ) ( x_test , y_test ) = ( f [ "x_test" ] , f [ "y_test" ] ) def normalize ( x , y , batch_size ) : x = x . astype ( np . float32 ) / 255.0 y = y . astype ( np . int32 ) if data_format == "NCHW" : images = x . reshape ( ( - 1 , batch_size , 1 , x . shape [ 1 ] , x . shape [ 2 ] ) ) else : images = x . reshape ( ( - 1 , batch_size , x . shape [ 1 ] , x . shape [ 2 ] , 1 ) ) labels = y . reshape ( ( - 1 , batch_size ) ) return ( images , labels ) ( train_images , train_labels ) = normalize ( x_train , y_train , train_batch_size ) ( test_images , test_labels ) = normalize ( x_test , y_test , test_batch_size ) return ( ( train_images , train_labels ) , ( test_images , test_labels ) )
short_docstring: Load mnist dataset, return images and labels,
  if  dataset doesn't exist, then download it to directory that out_dir specified
short_docstring_tokens: Load mnist dataset return images and labels if dataset doesn ' t exist then download it to directory that out_dir specified
comment: """Load mnist dataset, return images and labels,
              if  dataset doesn't exist, then download it to directory that out_dir specified
  
      Args:
          train_batch_size (int, optional): batch size for train. Defaults to 100.
          test_batch_size (int, optional): batch size for test or evaluate. Defaults to 100.
          data_format (str, optional): data format. Defaults to "NCHW".
          url (str, optional): url to get mnist.npz. Defaults to "https://oneflow-public.oss-cn-beijing.aliyuncs.com/datasets/mnist.npz".
          hash_check (str, optional): file hash value. Defaults to "63d4344077849053dc3036b247fa012b2b381de53fd055a66b539dffd76cf08e".
          out_dir (str, optional): dir to save downloaded file. Defaults to "./".
  
      Returns:
          (train_images, train_labels), (test_images, test_labels)
      """