code: def format_optimize_result(
      optimize_result_dict: dict, calculate_accuracy: bool
  ) -> str:
      """
      Get a format string representation for optimization result
      """
      if calculate_accuracy is True:
          horizontal_line = " {0} {1} {2} {3}\n".format(
              "-" * 32, "-" * 22, "-" * 14, "-" * 22
          )
          repr_str = horizontal_line
          repr_str += (
              "| {0:^30} | {1:^20} | {2:^12} | {3:^20} |\n".format(
                  "method", "status", "latency(ms)", "metric value"
              )
          )
          repr_str += horizontal_line
          for method, result in optimize_result_dict.items():
              status = result["status"]
              latency = result.get("latency", "None")
              if latency != "None":
                  latency = sigfig.round(latency, sigfigs=5)
              accuracy = result.get("accuracy", "None")
              if accuracy != "None" and isinstance(accuracy, float):
                  accuracy = sigfig.round(accuracy, sigfigs=5)
              elif isinstance(accuracy, numbers.Real):
                  # support more types
                  accuracy = float(accuracy)
                  accuracy = sigfig.round(accuracy, sigfigs=5)
              else:
                  try:
                      import torch
  
                      # turn Tensor into float
                      if isinstance(accuracy, torch.Tensor):
                          accuracy = accuracy.item()
                          accuracy = sigfig.round(accuracy, sigfigs=5)
                  except ImportError:
                      pass
              method_str = (
                  f"| {method:^30} | {status:^20} | "
                  f"{latency:^12} | {accuracy:^20} |\n"
              )
              repr_str += method_str
          repr_str += horizontal_line
      else:
          horizontal_line = " {0} {1} {2}\n".format(
              "-" * 32, "-" * 22, "-" * 14
          )
          repr_str = horizontal_line
          repr_str += "| {0:^30} | {1:^20} | {2:^12} |\n".format(
              "method", "status", "latency(ms)"
          )
          repr_str += horizontal_line
          for method, result in optimize_result_dict.items():
              status = result["status"]
              latency = result.get("latency", "None")
              if latency != "None":
                  latency = sigfig.round(latency, sigfigs=5)
              method_str = (
                  f"| {method:^30} | {status:^20} | {latency:^12} |\n"
              )
              repr_str += method_str
          repr_str += horizontal_line
      return repr_str
  
imports: import numbers
  from typing import Dict
  import sigfig
  from .acceleration_option import AccelerationOption
label_desc: Use image node_id 2 for calling a global function with example usage: format_optimize_result(optimize_result_dict, calculate_accuracy) and returns: repr_str