code: def compile(src, target=None, options=None):
      if target is None:
          target = driver.get_current_target()
      backend = make_backend(target)
      # create backend
      if not isinstance(src, ASTSource):
          assert isinstance(
              src, str
          ), "source must be either AST or a filepath"
          src = IRSource(src)
      extra_options = src.parse_options()
      options = backend.parse_options(
          dict(options or dict(), **extra_options)
      )
      # create cache manager
      key = f"{triton_key()}-{src.hash()}-{backend.hash()}-{options.hash()}-{str(sorted(get_env_vars().items()))}"
      hash = hashlib.md5(key.encode("utf-8")).hexdigest()
      fn_cache_manager = get_cache_manager(hash)
      metadata_filename = f"{src.name}.json"
      metadata_group = (
          fn_cache_manager.get_group(metadata_filename) or {}
      )
      metadata_path = metadata_group.get(metadata_filename)
      if metadata_path is not None:
          # cache hit!
          metadata = json.loads(Path(metadata_path).read_text())
          return CompiledKernel(src, metadata_group)
      # initialize metadata
      metadata = {
          "hash": hash,
          "target": target,
          **options.__dict__,
          **get_env_vars(),
          **src.metadata(),
      }
      # run compilation pipeline  and populate metadata
      stages = dict()
      backend.add_stages(stages, options)
      first_stage = list(stages.keys()).index(src.ext)
      context = ir.context()
      ir.load_dialects(context)
      backend.load_dialects(context)
      module = src.make_ir(options, context)
      for ext, compile_ir in list(stages.items())[first_stage:]:
          next_module = compile_ir(module, metadata)
          metadata_group[f"{src.name}.{ext}"] = fn_cache_manager.put(
              next_module, f"{src.name}.{ext}"
          )
          module = next_module
      # write-back metadata
      metadata_group[metadata_filename] = fn_cache_manager.put(
          json.dumps(metadata, default=vars),
          metadata_filename,
          binary=False,
      )
      fn_cache_manager.put_group(metadata_filename, metadata_group)
      # return handle to compiled kernel
      return CompiledKernel(src, metadata_group)
  
imports: from __future__ import annotations
  import hashlib
  import json
  from .._C.libtriton import get_env_vars, ir
  from ..backends import backends
  from ..None import __version__
  from ..runtime.autotuner import OutOfResources
  from ..runtime.cache import get_cache_manager
  from ..runtime.driver import driver
  from ..backends.nvidia.compiler import InfoFromBackendForTensorMap
  from dataclasses import dataclass
  from .code_generator import ast_to_ttir
  from pathlib import Path
  import re
  import functools
  import os
label_desc: Use image node_id 4 for calling a global function with example usage: compile(src, target, options) and returns: CompiledKernel, CompiledKernel