code: def prep_and_run_test(num_workers, order, with_indices=False):
      length = 600
      indices = None
      if with_indices:
          indices = np.random.choice(length, length // 2, replace=False)
  
      with TemporaryDirectory() as folder:
          name = path.join(folder, "dataset.beton")
          sync_file = path.join(folder, "share")
          dataset = DummyDataset(length)
          writer = DatasetWriter(
              name, {"index": IntField(), "value": BytesField()}
          )
  
          writer.from_indexed_dataset(dataset)
  
          args = (num_workers, name, order, sync_file, folder, indices)
          if num_workers > 1:
              spawn(process_work, nprocs=num_workers, args=args)
          else:
              process_work(*((0,) + args))
  
          results = []
          for r in range(num_workers):
              array = np.load(path.join(folder, f"result-{r}.npy"))
              results.append(array)
  
          results = np.concatenate(results, 1)
  
          # For each epoch
          for i in range(results.shape[0]):
              if not with_indices:
                  if (
                      order == OrderOption.SEQUENTIAL
                      and i < results.shape[0] - 1
                  ):
                      assert_that(
                          (results[i] == results[i + 1]).all()
                      ).is_true()
                  if (
                      order != OrderOption.SEQUENTIAL
                      and i < results.shape[0] - 1
                  ):
                      assert_that(
                          (results[i] == results[i + 1]).all()
                      ).is_false()
  
                  epoch_content = Counter(results[i])
                  indices_gotten = np.array(
                      sorted(list(epoch_content.keys()))
                  )
                  assert_that(
                      np.all(np.arange(length) == indices_gotten)
                  ).is_true()
                  assert_that(min(epoch_content.values())).is_equal_to(
                      1
                  )
                  assert_that(
                      max(epoch_content.values())
                  ).is_less_than_or_equal_to(2)
              else:
                  assert_that(set(results[i])).is_equal_to(set(indices))
  
imports: from collections import defaultdict
  from tempfile import TemporaryDirectory
  from os import path
  from typing import Counter
  import pytest
  from assertpy import assert_that
  import numpy
  from torch.utils.data import Dataset, distributed
  from torch.multiprocessing import spawn, Queue
  from torch.distributed import init_process_group
  from ffcv.loader.loader import ORDER_TYPE, OrderOption
  from ffcv.writer import DatasetWriter
  from ffcv.fields import IntField, BytesField
  from ffcv import Loader
label_desc: Use image node_id 2 for calling a global function with example usage: prep_and_run_test(num_workers, order, with_indices) without return types