code: def extract_features(
      context: TuneContext,
      candidates: List[MeasureCandidate],
      results: Optional[List[RunnerResult]] = None,
      extractor: Optional[FeatureExtractor] = None,
  ):
      """Extract feature vectors and compute mean costs.
  
      Parameters
      ----------
      context: TuneContext
          The tuning context.
      candidates: List[MeasureCandidate]
          The measure candidates.
      results: Optional[List[RunnerResult]]
          The measured results, can be None if used in prediction.
      extractor: Optional[FeatureExtractor]
          The feature extractor.
  
      Returns
      -------
      new_features: List[np.ndarray]
          The extracted features.
      new_mean_costs: np.ndarray
          The mean costs.
      """
      extractor = extractor or PerStoreFeature(extract_workload=True)
  
      def _feature(feature: NDArray) -> np.ndarray:
          return feature.numpy().astype("float32")
  
      def _mean_cost(res: RunnerResult) -> float:
          if not res.run_secs:
              return 1e10
          return float(np.median([float(s) for s in res.run_secs]))
  
      new_features = [
          _feature(x)
          for x in extractor.extract_from(context, candidates)
      ]
      new_mean_costs = (
          np.array([_mean_cost(x) for x in results]).astype("float32")
          if results is not None
          else None
      )
      return new_features, new_mean_costs
  
imports: import glob
  import math
  import os
  import random
  import tempfile
  from collections import OrderedDict
  from itertools import chain
  from typing import Dict, List, NamedTuple, Optional, Tuple
  import numpy
  import torch
  import tvm
  from ...contrib.tar import tar, untar
  from ...runtime import NDArray
  from ...target import Target
  from ..cost_model import PyCostModel
  from ..database import JSONDatabase
  from ..feature_extractor import FeatureExtractor, PerStoreFeature
  from ..logging import get_logger
  from ..runner import RunnerResult
  from ..search_strategy import MeasureCandidate
  from ..tune_context import TuneContext
  from ..utils import derived_object, shash2hex
label_desc: Use image node_id 3 for calling a global function with example usage: extract_features(context, candidates, results, extractor) and returns: new_features,  new_mean_costs, feature, float, int