code: def create_and_validate(length, mode="raw", compile=False):
      dataset = DummyDataset(length)
  
      with NamedTemporaryFile() as handle:
          name = handle.name
          writer = DatasetWriter(
              name,
              {
                  "index": IntField(),
                  "value": RGBImageField(write_mode=mode),
              },
              num_workers=2,
          )
  
          writer.from_indexed_dataset(dataset, chunksize=5)
  
          reader = Reader(name)
          manager = OSCacheManager(reader)
          context = manager.schedule_epoch(np.array([0, 1]))
  
          Compiler.set_enabled(compile)
  
          with context:
              Decoder = RGBImageField().get_decoder_class()
              decoder = Decoder()
              decoder.accept_globals(
                  reader.metadata["f1"], manager.compile_reader()
              )
  
          decode = Compiler.compile(decoder.generate_code())
  
          assert_that(reader.metadata).is_length(length)
          buff = np.zeros((1, 128, 128, 3), dtype="uint8")
  
          for i in range(length):
              result = decode(
                  np.array([i]),
                  buff,
                  reader.metadata["f1"],
                  context.state,
              )[0]
              _, ref_image = dataset[i]
              assert_that(result.shape).is_equal_to(ref_image.shape)
              if mode == "jpg":
                  dist = np.abs(
                      ref_image.astype("float") - result.astype("float")
                  )
                  assert_that(dist.mean()).is_less_than(80)
              else:
                  assert_that(np.all(ref_image == result)).is_true()
  
imports: import numpy
  from tqdm import tqdm
  from assertpy import assert_that
  from torch.utils.data import Dataset
  import logging
  from time import time
  import os
  from assertpy import assert_that
  from tempfile import NamedTemporaryFile
  from ffcv.writer import DatasetWriter
  from ffcv.reader import Reader
  from ffcv.fields import IntField, RGBImageField
  from ffcv.pipeline.compiler import Compiler
  from ffcv.memory_managers import OSCacheManager
label_desc: Use image node_id 1 for calling a global function with example usage: create_and_validate(length, mode, compile) without return types