code: def test_check_metadata_inference(scitype, mtype, fixture_index):
      """Tests that check_is_mtype correctly infers metadata of examples.
  
      Parameters
      ----------
      scitype : str - scitype of fixture
      mtype : str - mtype of fixture
      fixture_index : int - index of fixture tuple with that scitype and mtype
  
      Raises
      ------
      RuntimeError if scitype is not defined or has no mtypes or examples
      AssertionError if example metadata is not correctly inferred
      error if check itself raises an error
      """
      # retrieve fixture for checking
      fixture, lossy, expected_metadata = get_examples(
          mtype=mtype, as_scitype=scitype, return_metadata=True
      ).get(fixture_index)
  
      # todo: possibly remove this once all checks are defined
      check_is_defined = (mtype, scitype) in check_dict.keys()
      # if the examples have no metadata to them, don't test
      metadata_provided = expected_metadata is not None
  
      # metadata keys to ignore
      # is_equal_index is not fully supported yet in inference
      EXCLUDE_KEYS = ["is_equal_index"]
  
      # metadata keys to ignore if mtype is lossy
      EXCLUDE_IF_LOSSY = [
          "feature_names",  # lossy mtypes do not have feature names
      ]
  
      # if mtype is in the list, add mtype specific keys to exclude
      if lossy:
          EXCLUDE_KEYS += EXCLUDE_IF_LOSSY
  
      if metadata_provided:
          expected_metadata = expected_metadata.copy()
          subset_keys = set(expected_metadata.keys()).difference(
              EXCLUDE_KEYS
          )
          expected_metadata = {
              key: expected_metadata[key] for key in subset_keys
          }
  
      # check fixtures that exist against checks that exist, full metadata query
      if fixture is not None and check_is_defined and metadata_provided:
          check_result = check_is_mtype(
              fixture,
              mtype,
              scitype,
              return_metadata=True,
              msg_return_dict="list",
          )
          metadata = check_result[2]
  
          # remove mtype & scitype key if exists, since comparison is on scitype level
          if "mtype" in metadata:
              del metadata["mtype"]
          if "scitype" in metadata:
              del metadata["scitype"]
  
          # remove keys that are not checked
          for key in EXCLUDE_KEYS:
              if key in metadata:
                  del metadata[key]
  
          # currently we do not check this field in metadata inference
  
          msg = (
              f"check_is_mtype returns wrong metadata on scitype {scitype}, "
              f"mtype {mtype}, fixture {fixture_index}, when querying full metadata. "
              f"returned: {metadata}; expected: {expected_metadata}"
          )
  
          assert metadata == expected_metadata, msg
  
      # check fixtures that exist against checks that exist
      if fixture is not None and check_is_defined and metadata_provided:
          for metadata_key in subset_keys:
              check_result = check_is_mtype(
                  fixture,
                  mtype,
                  scitype,
                  return_metadata=[metadata_key],
                  msg_return_dict="list",
              )
              metadata = check_result[2]
  
              # remove mtype & scitype key if exists, since comparison is on scitype level
              if "mtype" in metadata:
                  del metadata["mtype"]
              if "scitype" in metadata:
                  del metadata["scitype"]
  
              msg = (
                  f"check_is_mtype returns wrong metadata on scitype {scitype}, "
                  f"mtype {mtype}, fixture {fixture_index}, when querying "
                  f"metadata for metadata key {metadata_key}. "
                  f"returned: {metadata[metadata_key]}; "
                  f"expected: {expected_metadata[metadata_key]}"
              )
  
              assert (
                  metadata[metadata_key]
                  == expected_metadata[metadata_key]
              ), msg
  
file_path: sktime/sktime/datatypes/tests/test_check.py
imports: import numpy
  from sktime.datatypes._check import AMBIGUOUS_MTYPES, check_dict, check_is_mtype, check_is_scitype
  from sktime.datatypes._check import mtype
  from sktime.datatypes._check import scitype
  from sktime.datatypes._examples import get_examples
  from sktime.datatypes._registry import SCITYPE_LIST, scitype_to_mtype
label_desc: Use image node_id 6 for calling a global function with example usage: test_check_metadata_inference(scitype, mtype, fixture_index) without return types