code: def test_write_mnist(orca_context_fixture, use_api=False):
      sc = orca_context_fixture
      temp_dir = tempfile.mkdtemp()
  
      try:
          train_image_file = os.path.join(temp_dir, "train-images")
          train_label_file = os.path.join(temp_dir, "train-labels")
          output_path = os.path.join(temp_dir, "output_dataset")
  
          images = (
              np.array([[i] * 16 for i in range(20)])
              .reshape((20, 4, 4))
              .astype(np.uint8)
          )
          labels = (
              np.array(list(range(20))).reshape((20,)).astype(np.uint8)
          )
  
          _images_to_mnist_file(images, train_image_file)
          _labels_to_mnist_file(labels, train_label_file)
          if use_api:
              write_parquet(
                  "mnist",
                  "file://" + output_path,
                  image_file=train_image_file,
                  label_file=train_label_file,
              )
          else:
              write_mnist(
                  image_file=train_image_file,
                  label_file=train_label_file,
                  output_path="file://" + output_path,
              )
          data, schema = ParquetDataset._read_as_dict_rdd(
              "file://" + output_path
          )
          data = data.sortBy(lambda x: x["label"]).collect()
          images_load = np.reshape(
              np.stack([d["image"] for d in data]), (-1, 4, 4)
          )
          labels_load = np.stack([d["label"] for d in data])
  
          assert np.all(images_load == images)
          assert np.all(labels_load == labels_load)
  
      finally:
          shutil.rmtree(temp_dir)
  
file_path: BigDL/python/orca/test/bigdl/orca/data/test_write_parquet.py
imports: import tempfile
  import shutil
  import pytest
  import numpy
  import os
  from bigdl.orca.data.image.parquet_dataset import ParquetDataset
  from bigdl.orca.data.image.parquet_dataset import write_from_directory, write_parquet
  from bigdl.orca.data.image.utils import DType, FeatureType, SchemaField
  from bigdl.orca.data.image import write_mnist, write_voc
label_desc: Use image node_id 5 for calling a global function with example usage: test_write_mnist(orca_context_fixture, use_api) without return types