class_docstr: Takes the mean of the best models, where the models are ranked according to
  the value of an evaluation metric.
code: def train(
      self,
      all_model_outs: List[TimeSeries],
      target: TimeSeries = None,
      **kwargs,
  ) -> TimeSeries:
      metric_values = []
      self.n_models = len(all_model_outs)
      for i, model_out in enumerate(all_model_outs):
          if not self._override_models_used.get(i, True):
              metric_values.append(
                  np.inf if self.invert else -np.inf
              )  # worst-possible value
          elif target is None and self.metric_values is None:
              metric_values.append(1)
          elif target is not None and not isinstance(target, list):
              metric_values.append(
                  self.metric.value(
                      ground_truth=target, predict=model_out, **kwargs
                  )
              )
          elif isinstance(target, list):
              assert isinstance(model_out, list) and len(
                  model_out
              ) == len(target), (
                  f"If target is a list of time series, each model output should be a "
                  f"list with the same length, but target has length {len(target)}, "
                  f"while model output {i} is a {type(model_out).__name__} of length "
                  f"{len(model_out)}"
              )
              vals = [
                  self.metric.value(
                      ground_truth=y, predict=yhat, **kwargs
                  )
                  for y, yhat in zip(target, model_out)
              ]
              metric_values.append(np.mean(vals))
  
      if len(metric_values) == len(all_model_outs):
          self.metric_values = metric_values
      return self(all_model_outs, target)
  
imports: from abc import abstractmethod
  from collections import OrderedDict
  import copy
  import logging
  from typing import List, Optional, Union
  import numpy
  from merlion.evaluate.anomaly import TSADMetric
  from merlion.evaluate.forecast import ForecastMetric
  from merlion.utils import UnivariateTimeSeries, TimeSeries
  from merlion.utils.misc import AutodocABCMeta
label_desc: Use image node_id 7 for calling the ModelSelector obj's underlying member method code with example usage: obj.train(all_model_outs, target) and returns: self