code: def __init__(
      self,
      jit_cache: List[JitItem],
      input_rawbuffers: List[Buffer],
      var_vals: Dict[Variable, int],
  ):
      devices = [
          ji.prg.clprg.device
          if isinstance(ji.prg, CompiledASTRunner)
          else None
          for ji in jit_cache
      ]
      if (
          len(devices) == 0
          or not all_same(devices)
          or devices[0] is None
      ):
          raise GraphException
      self.device = devices[0]
      self.set_device()
  
      self.jit_cache = jit_cache
      self.input_replace = get_input_replace(
          jit_cache, input_rawbuffers
      )
      self.op_estimate, self.mem_estimate = get_jit_stats(jit_cache)
      self.jc_idxs_with_updatable_launch_dims = (
          get_jc_idxs_with_updatable_launch_dims(jit_cache)
      )
      self.jc_idxs_with_updatable_var_vals = (
          get_jc_idxs_with_updatable_var_vals(jit_cache)
      )
      self.jc_idxs_with_updatable_rawbufs = list(
          set([x[0] for x in self.input_replace.keys()])
      )
      self.updatable_nodes: Dict[
          int, Tuple[Any, Any, Any]
      ] = (
          {}
      )  # Dict[jc index] = tuple(graph node, node params, input kernel params)
  
      self.graph = self.graph_create()
      graph_node: Optional[ctypes._CData] = None
  
      for (j, i), input_name in self.input_replace.items():
          self.jit_cache[j].rawbufs[i] = input_rawbuffers[input_name]
      for j, ji in enumerate(self.jit_cache):
          prg: CompiledASTRunner = cast(CompiledASTRunner, ji.prg)
  
          c_deps = (
              (type(graph_node) * 1)(*(graph_node,))
              if graph_node is not None
              else None
          )
          (
              c_kernel_input_config,
              c_input_params,
          ) = encode_args_cuda_style(
              [cast(Buffer, x)._buf for x in ji.rawbufs],
              [var_vals[x] for x in prg.vars],
              *self.encode_args_info(),
          )  # noqa: E501
          c_node_params = self.build_kernel_node_params(
              prg,
              *cast(
                  Tuple[List[int], List[int]], prg.launch_dims(var_vals)
              ),
              c_kernel_input_config,
          )
          graph_node = self.graph_add_kernel_node(
              self.graph, c_deps, c_node_params
          )
  
          if (
              j in self.jc_idxs_with_updatable_launch_dims
              or j in self.jc_idxs_with_updatable_var_vals
              or j in self.jc_idxs_with_updatable_rawbufs
          ):
              self.updatable_nodes[j] = (
                  graph_node,
                  c_node_params,
                  c_input_params,
              )
  
      self.instance = self.graph_instantiate(self.graph)
  
imports: import ctypes
  from typing import Any, Optional, Tuple, Dict, List, cast
  import gpuctypes.cuda
  from tinygrad.helpers import init_c_var, encode_args_cuda_style, all_same
  from tinygrad.device import CompiledASTRunner, update_stats, Buffer
  from tinygrad.runtime.ops_cuda import check, cu_time_execution
  from tinygrad.shape.symbolic import Variable
  from tinygrad.jit import JitItem, get_input_replace, get_jit_stats, get_jc_idxs_with_updatable_launch_dims, get_jc_idxs_with_updatable_var_vals, GraphException
label_desc: Use image node_id 1 to create a new CUDAGraph object  with example: obj = CUDAGraph(jit_cache, input_rawbuffers, var_vals)