code: def _get_first_mtype_of_same_scitype(
      from_mtype, to_mtypes, varname="to_mtypes"
  ):
      """Return first mtype in list mtypes that has same scitype as from_mtype.
  
      Parameters
      ----------
      from_mtype : str - mtype of object to convert from
      to_mtypes : list of str - mtypes to convert to
      varname : str - name of variable to_mtypes, for error message
  
      Returns
      -------
      to_type : str - first mtype in to_mtypes that has same scitype as from_mtype
      """
      to_mtypes = _check_str_or_list_of_str(to_mtypes, obj_name=varname)
  
      if not isinstance(to_mtypes, list):
          raise TypeError(f"{varname} must be a str or a list of str")
  
      # no conversion of from_type is in the list
      if from_mtype in to_mtypes:
          return from_mtype
      # otherwise convert to first element of same scitype
      scitype = mtype_to_scitype(from_mtype)
      same_scitype_mtypes = [
          mtype
          for mtype in to_mtypes
          if mtype_to_scitype(mtype) == scitype
      ]
      if len(same_scitype_mtypes) == 0:
          raise TypeError(
              f"{varname} contains no mtype compatible with the scitype of obj, "
              f"which is {scitype}. Value of {varname} is: {to_mtypes}"
          )
      to_type = same_scitype_mtypes[0]
      return to_type
  
file_path: sktime/sktime/datatypes/_convert.py
imports: from copy import deepcopy
  import numpy
  import pandas
  from sktime.datatypes._check import mtype
  from sktime.datatypes._hierarchical import convert_dict_Hierarchical
  from sktime.datatypes._panel import convert_dict_Panel
  from sktime.datatypes._proba import convert_dict_Proba
  from sktime.datatypes._registry import mtype_to_scitype
  from sktime.datatypes._series import convert_dict_Series
  from sktime.datatypes._table import convert_dict_Table
label_desc: Use image node_id 3 for calling a global function with example usage: _get_first_mtype_of_same_scitype(from_mtype, to_mtypes, varname) and returns: to_type, from_mtype