code: def generate_order_inner(
      seed, page_to_samples_array, page_sizes, result, buffer_size=6
  ):
      num_pages = len(page_sizes)
      random.seed(seed)
      np.random.seed(seed)
      current_pages = [0]
      current_pages.remove(0)  # Force the type
      for page_ix in range(num_pages):
          page_size = page_sizes[page_ix]
          random.shuffle(page_to_samples_array[page_ix, :page_size])
      next_page = 0
      page_order = np.random.permutation(num_pages)
      samples_consumed = np.zeros_like(page_sizes)
      for s_ix in range(result.shape[0]):
          while (
              next_page < num_pages and len(current_pages) < buffer_size
          ):
              page_to_add = page_order[next_page]
              if page_sizes[page_to_add] > 0:
                  current_pages.append(page_order[next_page])
              next_page += 1
          selected_page_ix = np.random.randint(0, len(current_pages))
          page = current_pages[selected_page_ix]
          result[s_ix] = page_to_samples_array[
              page, samples_consumed[page]
          ]
          samples_consumed[page] += 1
          if samples_consumed[page] >= page_sizes[page]:
              current_pages.remove(page)
  
file_path: ffcv/ffcv/traversal_order/quasi_random.py
imports: import random
  from typing import Sequence, TYPE_CHECKING
  from numba import njit
  import numpy
  from torch.utils.data import DistributedSampler
  from .base import TraversalOrder
label_desc: Use image node_id 1 for calling a global function with example usage: generate_order_inner(seed, page_to_samples_array, page_sizes, result, buffer_size) without return types