code: def make_dataset_fn(
      feature_columns,
      label_columns,
      sample_weight_col,
      metadata,
      input_shapes,
      label_shapes,
      output_names,
  ):
      # Check if any of the columns are only SparseVector
      has_sparse_col = any(
          metadata[col]["is_sparse_vector_only"]
          for col in label_columns + feature_columns
      )
  
      reshape = TFKerasUtil._reshape_fn(
          sample_weight_col, feature_columns, label_columns, metadata
      )
  
      prep_data_tf_keras = TFKerasUtil._prep_data_fn(
          has_sparse_col,
          sample_weight_col,
          feature_columns,
          label_columns,
          input_shapes,
          label_shapes,
          output_names,
      )
  
      def fn(
          reader, batch_size, is_batch_reader, shuffle=True, cache=False
      ):
          from petastorm.tf_utils import make_petastorm_dataset
  
          # Samples come from Petastorm reader are already shuffled if needed.
          # We don't need to shuffle again in Tensorflow dataset.
          dataset = make_petastorm_dataset(reader)
          if is_batch_reader:
              dataset = dataset.apply(tf.data.experimental.unbatch())
  
          # cache() can only be applied without shuffle to generate same samples per epoch.
          if cache and not shuffle:
              dataset = dataset.cache()
  
          # Use tf.data.Dataset.repeat() to set up an infinite iterator
          # and to enable ranks to perform training and validation with
          # unequal number of samples.
          # FIXME(chongxiaoc): Use a very large number (10^9) for enough loops.
          # None and -1 are not working with petastorm dataset for repeating.
          # Verify this parameter again in future with new TF and Petastorm versions.
          dataset = dataset.repeat(1000000000)
  
          # Decompress sparse data if necessary
          if has_sparse_col:
              dataset = dataset.batch(1).map(reshape)
  
          dataset = dataset.batch(batch_size).map(prep_data_tf_keras)
          if hasattr(tf.data, "AUTOTUNE"):
              dataset = dataset.prefetch(tf.data.AUTOTUNE)
          else:
              dataset = dataset.prefetch(1)
          return dataset
  
      return tf.autograph.experimental.do_not_convert(fn)
  
imports: import io
  from packaging import version
  import h5py
  import numpy
  import tensorflow
  from horovod.runner.common.util import codec
  from horovod.spark.common import constants, params
  from horovod.spark.keras import optimizer, remote
label_desc: Use image node_id 2 for calling the TFKerasUtil obj's underlying member method code with example usage: obj.make_dataset_fn(feature_columns, label_columns, sample_weight_col, metadata, input_shapes, label_shapes, output_names) and returns: tf, dataset