code: def search_plan(sym, ntrial=6, type_dict=None, **kwargs):
      """Quickly heurestic search over possible plans to find good memory plan.
  
      Parameters
      ----------
      sym : symbolic
         Symbolic configurations
  
      ntrial: integer
         Additional grid search steps
      """
      history = []
      threshold = 0
      min_threshold = None
      min_cost = None
      nbegin = 3
  
      for k in range(nbegin):
          info = {}
          sym = make_mirror_plan(
              sym, threshold=threshold, plan_info=info, **kwargs
          )
          cost = get_cost(sym, type_dict, **kwargs)
          save_size = info["save_size"] >> 20
          local_size = info["max_size"] >> 20
          guess = int(math.sqrt(save_size * local_size / 2))
          if min_cost is None or min_cost > cost:
              min_cost = cost
          if min_threshold is None or local_size < min_threshold:
              min_threshold = local_size
          print(
              "Search threshold=%d MB, cost=%d MB" % (threshold, cost)
          )
          history.append((cost, threshold, sym))
          threshold = guess
  
      max_threshold = threshold * math.sqrt(2)
      step = int((max_threshold - min_threshold) / ntrial)
      threshold = min_threshold + step
      if step > 0:
          for k in range(ntrial):
              sym = make_mirror_plan(
                  sym, threshold=threshold, plan_info=info, **kwargs
              )
              cost = get_cost(sym, type_dict, **kwargs)
              print(
                  "Search threshold=%d MB, cost=%d MB"
                  % (threshold, cost)
              )
              history.append((cost, threshold, sym))
              threshold += step
  
      history.sort(key=lambda x: x[0])
      cost, threshold, sym = history[0]
      print(
          "Find best plan with threshold=%d, cost=%d MB"
          % (threshold, cost)
      )
      return sym
  
file_path: insightface/recognition/subcenter_arcface/symbol/memonger_v2.py
imports: import mxnet
  import math
label_desc: Use image node_id 5 for calling a global function with example usage: search_plan(sym, ntrial, type_dict) and returns: sym