code: def check_is_error_msg(
      msg, var_name="obj", allowed_msg=None, raise_exception=False
  ):
      """Format and possibly raise error message from check_is_mtype or check_is_scitype.
  
      Parameters
      ----------
      msg: dict[str, str]
          error message from check_is_scitype, or from check_is_mtype with dict return
      var_name: str, optional, default="obj"
          name of input in error messages
      allowed_msg: str, optional, default=None
          message component detailing allowed mtypes or scitype combinations
      raise_exception: bool or Exception, optional, default=False
          whether to raise exception or return error message
          if False, returns formatted error message
          if True, raises TypeError with formatted error message
          if Exception, raises that Exception with formatted error message
  
      Returns
      -------
      str - formatted error message
      """
      msg_invalid_input = (
          f"{var_name} must be in an sktime compatible format. {allowed_msg}"
          f" See the data format tutorial examples/AA_datatypes_and_datasets.ipynb. "
          f"If you think the data is already in an sktime supported input format, "
          f"run sktime.datatypes.check_raise(data, mtype) to diagnose the error, "
          f"where mtype is the string of the type specification you want. "
          f"Error message for checked mtypes, in format [mtype: message], as follows:"
      )
      for mtype, err in msg.items():
          msg_invalid_input += f" [{mtype}: {err}] "
  
      if raise_exception is True:
          raise TypeError(msg_invalid_input)
      elif raise_exception is False:
          return msg_invalid_input
      else:
          raise raise_exception(msg_invalid_input)
  
file_path: sktime/sktime/datatypes/_check.py
imports: from typing import List, Union
  import numpy
  from sktime.datatypes._alignment import check_dict_Alignment
  from sktime.datatypes._common import _metadata_requested, _ret
  from sktime.datatypes._hierarchical import check_dict_Hierarchical
  from sktime.datatypes._panel import check_dict_Panel
  from sktime.datatypes._proba import check_dict_Proba
  from sktime.datatypes._registry import AMBIGUOUS_MTYPES, SCITYPE_LIST, mtype_to_scitype
  from sktime.datatypes._series import check_dict_Series
  from sktime.datatypes._table import check_dict_Table
  from sktime.utils.warnings import warn
label_desc: Use image node_id 7 for calling a global function with example usage: check_is_error_msg(msg, var_name, allowed_msg, raise_exception) and returns: msg_invalid_input