code: def derive_similarity_tag(dag, log_base=1.618):
      """Derive the tag for similarity check from one computational DAG.
      The DAGs with the same tag are considered as similar tasks.
  
      The tag format is <op1-tag>_<op2-tag> ... <log(flop)>.
  
      If the tag is "", then the task is not considered to be similar to any other tasks.
  
      Parameters
      ----------
      dag: ComputeDAG
          The input computational DAG
      log_base: float = 1.618
          The base of log to normalize FLOPS
  
      Returns
      -------
      tag: str
          The tag of this computational DAG.
      """
      ret = ""
      for op in dag.ops:
          tag = op.attrs.get("auto_scheduler_task_scheduler_tag", None)
          if tag:
              ret += op.attrs["auto_scheduler_task_scheduler_tag"] + "_"
      if ret:
          ret += "%d" % int(math.log(dag.flop_ct + 1, log_base))
      return ret
  
imports: import os
  import time
  import math
  import logging
  import numpy
  from .search_policy import SearchPolicy, SketchPolicy, PreloadMeasuredStates
  from .cost_model import RandomModel, XGBModel
  from .utils import array_mean
  from .measure import ProgramMeasurer
  from .measure_record import RecordReader
  from .None import _ffi_api
label_desc: Use image node_id 2 for calling a global function with example usage: derive_similarity_tag(dag, log_base) and returns: ret