code: def single_experiment(
      trend: str, gen: Generator, file_name: str
  ) -> None:
      """
      Wraps and blocks the main simulation so that the maximum amount of memory
      can be controlled on multi processor systems when executing in parallel
      """
  
      res = np.zeros(EX_SIZE)
      output: np.ndarray = np.zeros(
          (len(cast(np.ndarray, PERCENTILES)), len(TIME_SERIES_LENGTHS))
      )
      for col, nobs in enumerate(TIME_SERIES_LENGTHS):
          remaining = EX_SIZE
          finished = 0
          block_size = int(2**20.0 * MAX_MEMORY_SIZE / (8.0 * nobs))
          for _ in range(0, EX_SIZE, block_size):
              if block_size < remaining:
                  count = block_size
              else:
                  count = remaining
              st = finished
              en = finished + count
              _trend: UnitRootTrend
              if trend == "n":
                  _trend = "n"
              elif trend == "c":
                  _trend = "c"
              elif trend == "ct":
                  _trend = "ct"
              else:
                  _trend = "ctt"
              res[st:en] = adf_simulation(nobs, _trend, count, gen)
              finished += count
              remaining -= count
          output[:, col] = np.percentile(res, PERCENTILES)
      np.savez(file_name, results=output)
  
file_path: arch/arch/unitroot/critical_values/simulation/adf_z_critical_values_simulation_joblib.py
imports: from __future__ import annotations
  import argparse
  import os
  import random
  from typing import cast
  from adf_simulation import OUTPUT_PATH, PERCENTILES, TIME_SERIES_LENGTHS, TRENDS, adf_simulation
  import colorama
  from joblib import Parallel, delayed
  import numpy
  from numpy.random import PCG64, Generator, SeedSequence
  import psutil
  from arch.typing import UnitRootTrend
label_desc: Use image node_id 1 for calling a global function with example usage: single_experiment(trend, gen, file_name) without return types