code: def generate_anomaly_blocks(
      timeseries_length, block_number, mean_block_size=5
  ):
      """Returns blocks of indices to insert anomalies into.
  
      :param timeseries_length: int
          length of the time series into which we want to inject anomalies
      :param block_number: int
          initial number of blocks; may change in the output
      :param mean_block_size: float
          initial average number of indices per block; may change in the output
  
      :return: Dict[list, any]
          contains a list of blocks of indices, number of blocks and a list of size of blocks
      """
      anomaly_start = np.random.choice(
          timeseries_length - 1, block_number, replace=False
      )
      anomaly_start = np.sort(anomaly_start)
      interval_length = np.random.poisson(
          lam=mean_block_size, size=block_number
      )
      anomaly_blocks = []
      for i in range(len(anomaly_start)):
          block_lower = anomaly_start[i]
          block_upper = min(
              timeseries_length,
              anomaly_start[i] + interval_length[i] + 1,
          )
          anomaly_blocks.append(list(range(block_lower, block_upper)))
      anomaly_block_list = []
      anomaly_block_list.append(anomaly_blocks[0])
      for j in range(1, len(anomaly_blocks)):
          if anomaly_blocks[j][0] <= anomaly_block_list[-1][-1] + 1:
              anomaly_block_list[-1] = list(
                  np.sort(
                      np.array(
                          (
                              list(
                                  set(
                                      anomaly_block_list[-1]
                                      + anomaly_blocks[j]
                                  )
                              )
                          )
                      )
                  )
              )
          else:
              anomaly_block_list.append(anomaly_blocks[j])
  
      return {
          "anomaly_block_list": anomaly_block_list,
          "block_number": len(anomaly_block_list),
          "block_size": [
              len(anomaly_block_list[x])
              for x in range(len(anomaly_block_list))
          ],
      }
  
imports: import datetime
  import numpy
  import pandas
  from greykite.common.testing_utils import generate_df_for_tests
label_desc: Use image node_id 1 for calling a global function with example usage: generate_anomaly_blocks(timeseries_length, block_number, mean_block_size) and returns: dict