class_docstr: The nonparametric surrogate predicts a model's performance on a new dataset
  as the average performance across all known datasets.
  
  Performances are either predicted as ranks or actual values.
class_docstr_tok: ["The","nonparametric","surrogate","predicts","a","model","'s","performance","on","a","new","dataset","as","the","average","performance","across","all","known","datasets",".","Performances","are","either","predicted","as","ranks","or","actual","values","."]
code: def _predict(
      self, X: List[Config[ModelConfig]]
  ) -> npt.NDArray[np.float32]:
      if self.use_dataset_features:
          embeddings = self.config_transformer.transform(X)
  
      results = []
      for i, x in enumerate(X):
          performance = self.model_performances_[x.model]
          if self.use_dataset_features:
              dataset_embedding = embeddings[i][None, :]  # type: ignore
              # Compute distances
              distances = euclidean_distances(
                  self.dataset_features_, dataset_embedding
              )
              similarity = 1 / distances
              similarity[distances == 0] = float("inf")
              # Compute weighted prediction
              weights = similarity / np.sum(similarity)
              results.append((performance * weights).sum(0))
          else:
              results.append(performance.mean(0))
  
      return np.stack(results)
  
file_path: gluonts/src/gluonts/nursery/tsbench/src/tsbench/surrogate/nonparametric.py
imports: from collections import defaultdict
  from typing import Dict, List, Optional
  import numpy
  import numpy.typing
  from sklearn.metrics.pairwise import euclidean_distances
  from tsbench.config import Config, ModelConfig
  from tsbench.config.model.models import SeasonalNaiveModelConfig
  from tsbench.evaluations.tracking import ModelTracker
  from ._base import DatasetFeaturesMixin, OutputNormalization, Surrogate
  from ._factory import register_surrogate
  from .transformers import ConfigTransformer
label_desc: Use image node_id 3 for calling the NonparametricSurrogate obj's underlying member method code with example usage: obj._predict(X) and returns: np