code: def mtype(
      obj,
      as_scitype: Union[str, List[str]] = None,
      exclude_mtypes=AMBIGUOUS_MTYPES,
  ):
      """Infer the mtype of an object considered as a specific scitype.
  
      Parameters
      ----------
      obj : object to infer type of - any type, should comply with some mtype spec
          if as_scitype is provided, this needs to be mtype belonging to scitype
      as_scitype : str, list of str, or None, optional, default=None
          name of scitype(s) the object "obj" is considered as, finds mtype for that
          if None (default), does not assume a specific as_scitype and tests all mtypes
              generally, as_scitype should be provided for maximum efficiency
          valid scitype type strings are in datatypes.SCITYPE_REGISTER (1st column)
      exclude_mtypes : list of str, default = AMBIGUOUS_MTYPES
          which mtypes to ignore in inferring mtype, default = ambiguous ones
  
      Returns
      -------
      str - the inferred mtype of "obj", a valid mtype string
              or None, if obj is None
          mtype strings with explanation are in datatypes.MTYPE_REGISTER
  
      Raises
      ------
      TypeError if no type can be identified, or more than one type is identified
      """
      if obj is None:
          return None
  
      if as_scitype is not None:
          as_scitype = _coerce_list_of_str(
              as_scitype, var_name="as_scitype"
          )
          for scitype in as_scitype:
              _check_scitype_valid(scitype)
  
      m_plus_scitypes = [
          (x[0], x[1])
          for x in check_dict.keys()
          if x[0] not in exclude_mtypes
      ]
  
      if as_scitype is not None:
          m_plus_scitypes = [
              (x[0], x[1])
              for x in m_plus_scitypes
              if x[1] in as_scitype
          ]
  
      # collects mtypes that are tested as valid for obj
      mtypes_positive = []
  
      # collects error messages from mtypes that are tested as invalid for obj
      mtypes_negative = dict()
  
      for m_plus_scitype in m_plus_scitypes:
          valid, msg, _ = check_is_mtype(
              obj,
              mtype=m_plus_scitype[0],
              scitype=m_plus_scitype[1],
              return_metadata=[],
              msg_return_dict="list",
          )
          if valid:
              mtypes_positive += [m_plus_scitype[0]]
          else:
              mtypes_negative[m_plus_scitype[0]] = msg
  
      if len(mtypes_positive) > 1:
          raise TypeError(
              f"Error in check_is_mtype, more than one mtype identified:"
              f" {mtypes_positive}"
          )
  
      if len(mtypes_positive) < 1:
          msg = ""
          for mtype, error in mtypes_negative.items():
              msg += f"{mtype}: {error}\r\n"
          msg = (
              f"No valid mtype could be identified for object of type {type(obj)}. "
              f"Errors returned are as follows, in format [mtype]: [error message] \r\n"
          ) + msg
          raise TypeError(msg)
  
      return mtypes_positive[0]
  
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 5 for calling a global function with example usage: mtype(obj, as_scitype, exclude_mtypes) and returns: mtypes_positive, None