code: def check_is_mtype(
      obj,
      mtype: Union[str, List[str]],
      scitype: str = None,
      return_metadata=False,
      var_name="obj",
      msg_return_dict=None,
  ):
      """Check object for compliance with mtype specification, return metadata.
  
      Parameters
      ----------
      obj - object to check
      mtype: str or list of str, mtype to check obj as
          valid mtype strings are in datatypes.MTYPE_REGISTER (1st column)
      scitype: str, optional, scitype to check obj as; default = inferred from mtype
          if inferred from mtype, list elements of mtype need not have same scitype
          valid mtype strings are in datatypes.SCITYPE_REGISTER (1st column)
      return_metadata - bool, str, or list of str, optional, default=False
          if False, returns only "valid" return
          if True, returns all three return objects
          if str, list of str, metadata return dict is subset to keys in return_metadata
      var_name: str, optional, default="obj"
          name of input in error messages
      msg_return_dict: str, "list" or "dict", optional, default="list"
          whether returned msg, if returned is a str, dict or list
          if "list", msg is str if mtype is str, list of str if mtype is list
          if "dict", msg is dict if mtype is str, list of str if mtype is list,
          if dict, has with mtype as key and error message for mtype as value
  
      Returns
      -------
      valid: bool - whether obj is a valid object of mtype/scitype
      msg: str or list/dict of str - error messages if object is not valid, otherwise None
          list or dict type is controlled via msg_return_dict
          if str: error message for tested mtype
          it list: list of len(mtype) with message per mtype if list, same order as mtype
          if dict: dict with mtype as key and error message for mtype as value
          returned only if return_metadata is True or str, list of str
      metadata: dict - metadata about obj if valid, otherwise None
              returned only if return_metadata is True or str, list of str
          Keys populated depend on (assumed, otherwise identified) scitype of obj.
          Always returned:
              "mtype": str, mtype of obj (assumed or inferred)
              "scitype": str, scitype of obj (assumed or inferred)
          For scitype "Series":
              "is_univariate": bool, True iff series has one variable
              "is_equally_spaced": bool, True iff series index is equally spaced
              "is_empty": bool, True iff series has no variables or no instances
              "has_nans": bool, True iff the series contains NaN values
          For scitype "Panel":
              "is_univariate": bool, True iff all series in panel have one variable
              "is_equally_spaced": bool, True iff all series indices are equally spaced
              "is_equal_length": bool, True iff all series in panel are of equal length
              "is_empty": bool, True iff one or more of the series in the panel are empty
              "is_one_series": bool, True iff there is only one series in the panel
              "has_nans": bool, True iff the panel contains NaN values
              "n_instances": int, number of instances in the panel
          For scitype "Table":
              "is_univariate": bool, True iff table has one variable
              "is_empty": bool, True iff table has no variables or no instances
              "has_nans": bool, True iff the panel contains NaN values
              "n_instances": int, number of instances/rows in the table
          For scitype "Alignment":
              currently none
  
      Raises
      ------
      TypeError if no checks defined for mtype/scitype combination
      TypeError if mtype input argument is not of expected type
      """
      mtype = _coerce_list_of_str(mtype, var_name="mtype")
  
      valid_keys = check_dict.keys()
  
      # we loop through individual mtypes in mtype and see whether they pass the check
      #  for each check we remember whether it passed and what it returned
  
      # initialize loop variables
      if msg_return_dict is None:
          # todo 0.26.0: remove this warning, and change default to "dict"
          warn(
              "From sktime 0.26.0 onwards, msg return of check_is_mtype "
              "will default to dict if mtype is a list. "
              "To retain the old behaviour, set msg_return_dict='list' explicitly. "
              "To move to the new behaviour, set msg_return_dict='dict' explicitly. "
              "Setting msg_return_dict explicitly will silence the warning."
          )
          msg = []
          msg_return_dict = "list"
      elif msg_return_dict == "list":
          msg = []
      elif msg_return_dict == "dict":
          msg = dict()
  
      found_mtype = []
      found_scitype = []
  
      for m in mtype:
          if scitype is None:
              scitype_of_m = mtype_to_scitype(m)
          else:
              _check_scitype_valid(scitype)
              scitype_of_m = scitype
          key = (m, scitype_of_m)
          if (m, scitype_of_m) not in valid_keys:
              raise TypeError(
                  f"no check defined for mtype {m}, scitype {scitype_of_m}"
              )
  
          res = check_dict[key](
              obj, return_metadata=return_metadata, var_name=var_name
          )
  
          if _metadata_requested(return_metadata):
              check_passed = res[0]
          else:
              check_passed = res
  
          if check_passed:
              found_mtype.append(m)
              found_scitype.append(scitype_of_m)
              final_result = res
          elif _metadata_requested(return_metadata):
              if msg_return_dict == "list":
                  msg.append(res[1])
              else:
                  msg[m] = res[1]
  
      # there are three options on the result of check_is_mtype:
      # a. two or more mtypes are found - this is unexpected and an error with checks
      if len(found_mtype) > 1:
          raise TypeError(
              f"Error in check_is_mtype, more than one mtype identified: {found_mtype}"
          )
      # b. one mtype is found - then return that mtype
      elif len(found_mtype) == 1:
          if _metadata_requested(return_metadata):
              # add the mtype return to the metadata
              final_result[2]["mtype"] = found_mtype[0]
              final_result[2]["scitype"] = found_scitype[0]
              # final_result already has right shape and dependency on return_metadata
              return final_result
          else:
              return True
      # c. no mtype is found - then return False and all error messages if requested
      else:
          if len(msg) == 1:
              msg = msg[0]
  
          return _ret(False, msg, None, return_metadata)
  
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 3 for calling a global function with example usage: check_is_mtype(obj, mtype, scitype, return_metadata, var_name, msg_return_dict) and returns: _ret, final_result, True