code: def get_anomalies(
      insights: pd.DataFrame,
      observed_series: Union[pd.Series, list],
      cooldown: int = 1,
  ) -> np.ndarray:
      """
      Simple procedure for unsupervised anomaly detection in time series forecasting.
      Uses ICP analysis block output so that any true value falling outside of the lower and upper bounds is tagged as anomalous.
  
      :param insights: dataframe with row insights used during the `.explain()` phase of all analysis blocks.
      :param observed_series: true values from the predicted time series. If empty, no anomalies are flagged.
      :param cooldown: minimum amount of observations (assuming regular sampling frequency) that need to pass between two consecutive anomalies.
  
      :return: np.ndarray of boolean flags, indicating anomalous behavior for each predicted value.
      """  # noqa
      anomalies = []
      counter = 0
  
      # cast to float (safe, we only call this method if series is numerical)
      try:
          observed_series = [float(value) for value in observed_series]
      except (TypeError, ValueError):
          return [None for _ in observed_series]
  
      lower_bounds = insights["lower"].tolist()
      upper_bounds = insights["upper"].tolist()
  
      for (l, u), t in zip(
          zip(lower_bounds, upper_bounds), observed_series
      ):
          if t is not None:
              if isinstance(l, list):
                  anomaly = not (l[0] <= t <= u[0])
              else:
                  anomaly = not (l <= t <= u)
  
              if anomaly and (counter == 0 or counter >= cooldown):
                  anomalies.append(
                      anomaly
                  )  # new anomaly event triggers, reset counter
                  counter = 1
              elif anomaly and counter < cooldown:
                  anomalies.append(
                      False
                  )  # overwrite as not anomalous if still in cooldown
                  counter += 1
              else:
                  anomalies.append(anomaly)
                  counter = 0
          else:
              anomalies.append(None)
              counter += 1
  
      return np.array(anomalies)
  
file_path: lightwood/lightwood/analysis/nc/util.py
imports: from typing import Union, Optional
  import torch
  import numpy
  import pandas
  from torch.nn.functional import softmax
  from type_infer.dtype import dtype
label_desc: Use image node_id 7 for calling a global function with example usage: get_anomalies(insights, observed_series, cooldown) and returns: np, unknown