code: def time_linearizer(
      lin: Linearizer,
      rawbufs: List[Buffer],
      allow_test_size=True,
      max_global_size=65536,
      cnt=3,
      disable_cache=False,
      clear_l2=False,
  ) -> float:  # noqa: E501
      key = {
          "ast": str(lin.ast),
          "opts": str(lin.applied_opts),
          "allow_test_size": allow_test_size,
          "max_global_size": max_global_size,
          "clear_l2": clear_l2,
          "device": lin.opts.device,
      }  # noqa: E501
      if (
          not disable_cache
          and CACHELEVEL >= 2
          and (val := diskcache_get("time_linearizer", key)) is not None
      ):
          return min(val)
  
      dev = Device[lin.opts.device]
      assert isinstance(dev, Compiled)
  
      var_vals = {k: (k.max + k.min) // 2 for k in lin.ast.vars()}
      lib, global_size, local_size = _compile_linearizer(dev, lin)
      tms = _time_program(
          lin.ast,
          dev,
          lib,
          global_size,
          local_size,
          var_vals,
          rawbufs,
          max_global_size=max_global_size if allow_test_size else None,
          clear_l2=clear_l2,
          cnt=cnt,
          name=to_function_name(lin.name),
      )  # noqa: E501
  
      if CACHELEVEL >= 2:
          diskcache_put("time_linearizer", key, tms)
      return min(tms)
  
imports: from typing import Dict, List, cast, DefaultDict, Optional, Tuple, Callable
  import itertools, functools, random, math, time, multiprocessing, traceback, signal
  from tinygrad.device import Device, Compiled, Buffer, CompiledASTRunner
  from tinygrad.ops import MemBuffer, LazyOp
  from tinygrad.helpers import prod, flatten, DEBUG, CACHELEVEL, diskcache_get, diskcache_put, getenv, Context, colored, to_function_name
  from tinygrad.dtype import ImageDType
  from tinygrad.codegen.linearizer import Linearizer
  from collections import defaultdict
  from tinygrad.tensor import Tensor
  from tinygrad.shape.symbolic import sym_infer
  from tinygrad.codegen.kernel import Opt, OptOps
label_desc: Use image node_id 10 for calling a global function with example usage: time_linearizer(lin, rawbufs, allow_test_size, max_global_size, cnt, disable_cache, clear_l2) and returns: min, min