code: def convert_to(
      obj,
      to_type: str,
      as_scitype: str = None,
      store=None,
      store_behaviour: str = None,
      return_to_mtype: bool = False,
  ):
      """Convert object to a different machine representation, subject to scitype.
  
      Parameters
      ----------
      obj : object to convert - any type, should comply with mtype spec for as_scitype
      to_type : str - the mtype to convert "obj" to, a valid mtype string
          or list of str, this specifies admissible types for conversion to;
          if list, will convert to first mtype of the same scitype as obj
          valid mtype strings, with explanation, are in datatypes.MTYPE_REGISTER
      as_scitype : str, optional - name of scitype the object "obj" is considered as
          pre-specifying the scitype reduces the number of checks done in type inference
          valid scitype strings, with explanation, are in datatypes.SCITYPE_REGISTER
          default = inferred from mtype of obj, which is in turn inferred internally
      store : reference of storage for lossy conversions, default=None (no store)
          is updated by side effect if not None and store_behaviour="reset" or "update"
      store_behaviour : str, optional, one of None (default), "reset", "freeze", "update"
          "reset" - store is emptied and then updated from conversion
          "freeze" - store is read-only, may be read/used by conversion but not changed
          "update" - store is updated from conversion and retains previous contents
          None - automatic: "update" if store is empty and not None; "freeze", otherwise
      return_to_mtype: bool, optional (default=False)
          if True, also returns the str of the mtype converted to
  
      Returns
      -------
      converted_obj : to_type - object obj, or obj converted to target mtype as follows:
          case 1: mtype of obj is equal to to_type, or a list element of to_type
              no conversion happens, converted_obj = obj
          case 2: to_type is a str, and not equal to mtype of obj
              converted_obj is obj converted to to_type
          case 3: to_type is list of str, and mtype of obj is not in that list
              converted_obj is converted to the first mtype in to_type
                  that is of same scitype as obj
          case 4: if obj was None, converted_obj is also None
      to_type : str, only returned if ``return_to_mtype=True``
          mtype of ``converted_obj`` - useful of ``to_type`` was a list
  
      Raises
      ------
      TypeError if machine type of input "obj" is not recognized
      TypeError if to_type contains no mtype compatible with mtype of obj
      KeyError if conversion that would be conducted is not implemented
      TypeError or ValueError if inputs do not match specification
      """
      if obj is None:
          return None
  
      # input checks on to_type, as_scitype; coerce to_type, as_scitype to lists
      to_type = _check_str_or_list_of_str(to_type, obj_name="to_type")
  
      # sub-set a preliminary set of as_scitype from to_type, as_scitype
      if as_scitype is not None:
          # if not None, subset to types compatible between to_type and as_scitype
          as_scitype = _check_str_or_list_of_str(
              as_scitype, obj_name="as_scitype"
          )
          potential_scitypes = mtype_to_scitype(to_type)
          as_scitype = list(
              set(potential_scitypes).intersection(as_scitype)
          )
      else:
          # if None, infer from to_type
          as_scitype = mtype_to_scitype(to_type)
  
      # now further narrow down as_scitype by inference from the obj
      from_type = infer_mtype(obj=obj, as_scitype=as_scitype)
      as_scitype = mtype_to_scitype(from_type)
  
      converted_obj = convert(
          obj=obj,
          from_type=from_type,
          to_type=to_type,
          as_scitype=as_scitype,
          store=store,
          store_behaviour=store_behaviour,
          return_to_mtype=return_to_mtype,
      )
  
      return converted_obj
  
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 2 for calling a global function with example usage: convert_to(obj, to_type, as_scitype, store, store_behaviour, return_to_mtype) and returns: converted_obj, None