class_docstr: The VAE-based multivariate time series anomaly detector.
  This detector utilizes a variational autoencoder to infer the correlations between
  different time series and estimate the distribution of the reconstruction errors
  for anomaly detection.
  
  - paper: `Diederik P Kingma and Max Welling. Auto-Encoding Variational Bayes. 2013.
    <https://arxiv.org/abs/1312.6114>`_
class_docstr_tok: ["The","VAE-based","multivariate","time","series","anomaly","detector",".","This","detector","utilizes","a","variational","autoencoder","to","infer","the","correlations","between","different","time","series","and","estimate","the","distribution","of","the","reconstruction","errors","for","anomaly","detection",".","-","paper",":","`","Diederik","P","Kingma","and","Max","Welling",".","Auto-Encoding","Variational","Bayes",".","2013",".","<","https",":","\/\/arxiv.org\/abs\/1312.6114",">","`","_"]
code: def _get_anomaly_score(
      self,
      time_series: pd.DataFrame,
      time_series_prev: pd.DataFrame = None,
  ) -> pd.DataFrame:
      self.model.eval()
      ts = (
          pd.concat((time_series_prev, time_series))
          if time_series_prev is None
          else time_series
      )
      loader = RollingWindowDataset(
          ts,
          target_seq_index=None,
          shuffle=False,
          flatten=True,
          n_past=self.k,
          n_future=0,
          batch_size=self.batch_size,
      )
      ys, rs = [], []
      for y, _, _, _ in loader:
          ys.append(y)
          y = torch.tensor(y, dtype=torch.float, device=self.device)
          r = np.zeros(y.shape)
          for _ in range(self.num_eval_samples):
              recon_y, _, _, _ = self.model(y, None)
              r += recon_y.cpu().data.numpy()
          r /= self.num_eval_samples
          rs.append(r)
  
      scores = np.zeros((ts.shape[0],), dtype=float)
      test_scores = np.sum(
          np.abs(np.concatenate(rs) - np.concatenate(ys)), axis=1
      )
      scores[self.k - 1 :] = test_scores
      scores[: self.k - 1] = test_scores[0]
      return pd.DataFrame(
          scores[-len(time_series) :], index=time_series.index
      )
  
imports: from typing import Sequence
  import numpy
  import pandas
  from merlion.models.base import NormalizingConfig
  from merlion.models.anomaly.base import DetectorBase, DetectorConfig
  from merlion.post_process.threshold import AggregateAlarms
  from merlion.utils.misc import ProgressBar, initializer
  from merlion.models.utils.rolling_window_dataset import RollingWindowDataset
label_desc: Use image node_id 6 for calling the VAE obj's underlying member method code with example usage: obj._get_anomaly_score(time_series, time_series_prev) and returns: pd