code: def wrapper(
      n: int, trend: Literal["c", "ct"], b: int, seed: int = 0
  ) -> np.ndarray:
      """
      Wraps and blocks the main simulation so that the maximum amount of memory
      can be controlled on multi processor systems when executing in parallel
      """
      rng = RandomState()
      rng.seed(seed)
      remaining = b
      res = np.zeros(b)
      finished = 0
      block_size = int(2**20.0 * MAX_MEMORY_SIZE / (8.0 * n))
      for _ in range(0, b, block_size):
          if block_size < remaining:
              count = block_size
          else:
              count = remaining
          st = finished
          en = finished + count
          res[st:en] = dfgsl_simulation(n, trend, count, rng)
          finished += count
          remaining -= count
  
      return res
  
file_path: arch/arch/unitroot/critical_values/simulation/dfgls_critical_values_simulation.py
imports: from __future__ import annotations
  import datetime
  from typing import cast
  import numpy
  from numpy.linalg import pinv
  from numpy.random import RandomState
  from statsmodels.tools.parallel import parallel_func
  from arch.typing import Literal
label_desc: Use image node_id 1 for calling a global function with example usage: wrapper(n, trend, b, seed) and returns: res