code: def c2pyerror(err_msg):
      """Translate C API error message to python style.
  
      Parameters
      ----------
      err_msg : str
          The error message.
  
      Returns
      -------
      new_msg : str
          Translated message.
  
      err_type : str
          Detected error type.
      """
      arr = err_msg.split("\n")
      if arr[-1] == "":
          arr.pop()
      err_type = _find_error_type(arr[0])
      trace_mode = False
      stack_trace = []
      message = []
      for line in arr:
          if trace_mode:
              if line.startswith("        ") and len(stack_trace) > 0:
                  stack_trace[-1] += "\n" + line
              elif line.startswith("  "):
                  stack_trace.append(line)
              else:
                  trace_mode = False
          if not trace_mode:
              if line.startswith("Stack trace"):
                  trace_mode = True
              else:
                  message.append(line)
      out_msg = ""
      if stack_trace:
          out_msg += "Traceback (most recent call last):\n"
          out_msg += "\n".join(reversed(stack_trace)) + "\n"
      out_msg += "\n".join(message)
      return out_msg, err_type
  
imports: import ctypes
  import functools
  import os
  import re
  import sys
  import types
  from typing import Callable, Sequence, Optional
  import numpy
  from .None import libinfo
label_desc: Use image node_id 8 for calling a global function with example usage: c2pyerror(err_msg) and returns: out_msg,  err_type