code: def generate_data(spark, train_folder, test_folder):
      train_files = [
          os.path.join(dp, f)
          for dp, dn, filenames in os.walk(train_folder)
          for f in filenames
          if os.path.splitext(f)[1] == ".jpg"
      ]
      test_files = [
          os.path.join(dp, f)
          for dp, dn, filenames in os.walk(test_folder)
          for f in filenames
          if os.path.splitext(f)[1] == ".jpg"
      ]
  
      def extract_path_and_label(path):
          num = int(path.split("/")[-1].split(".")[0].split("_")[1])
          label = num // 81  # Assign the label
          return (path, label)
  
      train_df = spark.createDataFrame(
          map(extract_path_and_label, train_files), ["image", "label"]
      ).withColumn("label", col("label").cast(DoubleType()))
  
      test_df = spark.createDataFrame(
          map(extract_path_and_label, test_files), ["image", "label"]
      ).withColumn("label", col("label").cast(DoubleType()))
  
      return train_df, test_df
  
file_path: SynapseML/deep-learning/src/test/python/synapsemltest/dl/test_deep_vision_classifier.py
imports: import contextlib
  import os
  import shutil
  import tempfile
  import pytest
  from horovod.spark.common.store import LocalStore
  from pyspark.ml.evaluation import MulticlassClassificationEvaluator
  from pyspark.sql import SparkSession
  from pyspark.sql.functions import col
  from pyspark.sql.types import DoubleType
  from pytorch_lightning.callbacks import ModelCheckpoint
  from synapse.ml.dl import *
  from .conftest import CallbackBackend
  from .test_deep_vision_model import MyDummyCallback
label_desc: Use image node_id 3 for calling a global function with example usage: generate_data(spark, train_folder, test_folder) and returns: train_df,  test_df, path,  label