code: def test_adapts_to_series_scale(self):
      # Create a batch of two series with very different means and stddevs.
      freq = pd.DateOffset(hours=1)
      df = self._build_test_series(shape=[72, 2], freq=freq)
      mean0, mean1 = -5e6, 1e3
      stddev0, stddev1 = 1e3, 1e-2
      df.series0 = df.series0 * stddev0 + mean0
      df.series1 = df.series1 * stddev1 + mean1
      # Ask the model to impute values before and after the observations.
      df.reindex(
          pd.date_range(
              start=df.index[0] - 5 * freq,
              end=df.index[-1] + 5 * freq,
              freq=freq,
          )
      )
      predictions = anomaly_detection.detect_anomalies(
          df,
          # Predictive bounds will contain 68% of mass, roughly +- 1 stddev.
          anomaly_threshold=0.32,
          seed=test_util.test_seed(sampler_type="stateless"),
          num_samples=100,
          num_warmup_steps=50,
          jit_compile=False,
      )
      # The forecasts should have roughly the same mean and scale as the original
      # series.
      ones = tf.ones(
          predictions.mean[0, :].shape, dtype=predictions.mean.dtype
      )
      self.assertAllClose(
          predictions.mean[0, :],
          ones * np.nanmean(df.series0),
          atol=stddev0 * 4,
      )
      self.assertAllClose(
          predictions.mean[1, :],
          ones * np.nanmean(df.series1),
          atol=stddev1 * 4,
      )
  
      self.assertAllClose(
          predictions.lower_limit[0, :],
          predictions.mean[0, :] - stddev0,
          rtol=1e-3,
      )
      self.assertAllClose(
          predictions.lower_limit[1, :],
          predictions.mean[1, :] - stddev1,
          rtol=1e-3,
      )
      self.assertAllClose(
          predictions.upper_limit[0, :],
          predictions.mean[0, :] + stddev0,
          rtol=1e-3,
      )
      self.assertAllClose(
          predictions.upper_limit[1, :],
          predictions.mean[1, :] + stddev1,
          rtol=1e-3,
      )
  
file_path: probability/tensorflow_probability/python/sts/anomaly_detection/anomaly_detection_test.py
imports: from absl.testing import parameterized
  import numpy
  import pandas
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.sts import anomaly_detection
label_desc: Use image node_id 5 for calling the AnomalyDetectionTests obj's underlying member method code with example usage: obj.test_adapts_to_series_scale() without return types