code: def dataset_from_cache(fn):
      conn = sqlite3.connect(fn)
      cur = conn.cursor()
      cur.execute("SELECT * FROM beam_search")
      X, A = [], []
      for f in tqdm(cur.fetchall()):
          Xs, As = [], []
          try:
              lin = Linearizer(eval(f[0]))
              opts = pickle.loads(f[-1])
              for o in opts:
                  Xs.append(lin_to_feats(lin, use_sts=True))
                  As.append(actions.index(o))
                  lin.apply_opt(o)
              Xs.append(lin_to_feats(lin, use_sts=True))
              As.append(0)
          except Exception:
              pass
          X += Xs
          A += As
      return X, A
  
imports: import os, sys, sqlite3, pickle, random
  from tqdm import tqdm, trange
  from copy import deepcopy
  from tinygrad.nn import Linear
  from tinygrad.tensor import Tensor
  from tinygrad.nn.optim import Adam
  from tinygrad.nn.state import get_parameters, get_state_dict, safe_save, safe_load, load_state_dict
  from tinygrad.features.search import actions
  from extra.optimization.helpers import load_worlds, ast_str_to_lin, lin_to_feats, assert_same_lin
  from tinygrad.codegen.linearizer import Linearizer
  from tinygrad.helpers import getenv
  from tinygrad.ops import LazyOp, TernaryOps, BinaryOps, UnaryOps, ReduceOps, BufferOps, MemBuffer, ConstBuffer
  from tinygrad.dtype import dtypes
  from tinygrad.shape.shapetracker import ShapeTracker
  from tinygrad.shape.view import View
  from tinygrad.shape.symbolic import Variable
  from tinygrad.codegen.kernel import Opt, OptOps
label_desc: Use image node_id 1 for calling a global function with example usage: dataset_from_cache(fn) and returns: X,  A