code: def convert(
      obj,
      from_type: str,
      to_type: str,
      as_scitype: str = None,
      store=None,
      store_behaviour: str = None,
      return_to_mtype: bool = False,
  ):
      """Convert objects between different machine representations, subject to scitype.
  
      Parameters
      ----------
      obj : object to convert - any type, should comply with mtype spec for as_scitype
      from_type : str - the type to convert "obj" to, a valid mtype string
          valid mtype strings, with explanation, are in datatypes.MTYPE_REGISTER
      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 from_mtype
      as_scitype : str, optional - name of scitype the object "obj" is considered as
          default = inferred from from_type
          valid scitype strings, with explanation, are in datatypes.SCITYPE_REGISTER
      store : optional, reference of storage for lossy conversions, default=None (no ref)
          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`` converted to mtype ``to_type``
          if ``obj`` was ``None``, is ``None``
      to_type : str, only returned if ``return_to_mtype=True``
          mtype of ``converted_obj`` - useful of ``to_type`` was a list
  
      Raises
      ------
      KeyError if conversion is not implemented
      TypeError or ValueError if inputs do not match specification
      """
      if obj is None:
          return None
  
      # if to_type is a list, we do the following:
      # if on the list, then don't do a conversion (convert to from_type)
      # if not on the list, we find and convert to first mtype that has same scitype
      to_type = _get_first_mtype_of_same_scitype(
          from_mtype=from_type, to_mtypes=to_type, varname="to_type"
      )
  
      # input type checks
      if not isinstance(from_type, str):
          raise TypeError("from_type must be a str")
      if as_scitype is None:
          as_scitype = mtype_to_scitype(to_type)
      elif not isinstance(as_scitype, str):
          raise TypeError("as_scitype must be str or None")
      if store is not None and not isinstance(store, dict):
          raise TypeError("store must be a dict or None")
      if store_behaviour not in [None, "reset", "freeze", "update"]:
          raise ValueError(
              'store_behaviour must be one of "reset", "freeze", "update", or None'
          )
      if store_behaviour is None and store == {}:
          store_behaviour = "update"
      if store_behaviour is None and store != {}:
          store_behaviour = "freeze"
  
      key = (from_type, to_type, as_scitype)
  
      if key not in convert_dict.keys():
          raise NotImplementedError(
              "no conversion defined from type "
              + str(from_type)
              + " to "
              + str(to_type)
          )
  
      if store_behaviour == "freeze":
          store = deepcopy(store)
      elif store_behaviour == "reset":
          # note: this is a side effect on store
          store.clear()
      elif store_behaviour == "update":
          # store is passed to convert_obj by reference, unchanged
          # this "elif" is here for clarity, to cover all three values
          pass
      else:
          raise RuntimeError(
              "bug: unreachable condition error, store_behaviour has unexpected value"
          )
  
      converted_obj = convert_dict[key](obj, store=store)
  
      if return_to_mtype:
          return converted_obj, to_type
      else:
          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 1 for calling a global function with example usage: convert(obj, from_type, to_type, as_scitype, store, store_behaviour, return_to_mtype) and returns: None, converted_obj,  to_type, converted_obj