code: def generate_petastorm_dataset(
      output_url="file:///tmp/hello_world_dataset",
  ):
      rowgroup_size_mb = 256
  
      spark = (
          SparkSession.builder.config("spark.driver.memory", "2g")
          .master("local[2]")
          .getOrCreate()
      )
      sc = spark.sparkContext
  
      # Wrap dataset materialization portion. Will take care of setting up spark environment variables as
      # well as save petastorm specific metadata
      rows_count = 10
      with materialize_dataset(
          spark, output_url, HelloWorldSchema, rowgroup_size_mb
      ):
          rows_rdd = (
              sc.parallelize(range(rows_count))
              .map(row_generator)
              .map(lambda x: dict_to_spark_row(HelloWorldSchema, x))
          )
  
          spark.createDataFrame(
              rows_rdd, HelloWorldSchema.as_spark_schema()
          ).coalesce(10).write.mode("overwrite").parquet(output_url)
  
imports: import numpy
  from pyspark.sql import SparkSession
  from pyspark.sql.types import IntegerType
  from petastorm.codecs import ScalarCodec, CompressedImageCodec, NdarrayCodec
  from petastorm.etl.dataset_metadata import materialize_dataset
  from petastorm.unischema import dict_to_spark_row, Unischema, UnischemaField
label_desc: Use image node_id 2 for calling a global function with example usage: generate_petastorm_dataset(output_url) without return types