code: def add_spikes_asymmetric(
      ts: torch.Tensor, xi: List[float] = [1 / 50.0, 1 / 25.0]
  ):
      """
      Adds spikes to 15% of the time series in the form of heavy-tailed
      (Generalized Pareto) realizations.
  
      Arguments:
          ts: time series
          xi: [float, float], GenPareto heaviness parameter for [lower, upper] noise respectively
      """
      num_spikes = int(0.15 * ts.shape[0])
      half_num_spikes = [int(num_spikes / 2)]
      half_num_spikes.append(num_spikes - half_num_spikes[0])
      spike_direction = [-1, 1]
  
      indices_for_gp_spikes = np.random.choice(
          np.arange(len(ts)), replace=False, size=num_spikes
      )
  
      idx = 0
      spikes = (
          stats.genpareto(xi[idx]).rvs(half_num_spikes[idx])
          * spike_direction[idx]
      )
      ts[indices_for_gp_spikes[: half_num_spikes[0]]] += spikes
  
      idx = 1
      spikes = (
          stats.genpareto(xi[idx]).rvs(half_num_spikes[idx])
          * spike_direction[idx]
      )
      ts[indices_for_gp_spikes[half_num_spikes[0] :]] += spikes
  
      return ts
  
file_path: gluonts/src/gluonts/nursery/spliced_binned_pareto/data_functions.py
imports: from typing import List
  import numpy
  from scipy import stats
  import torch
label_desc: Use image node_id 4 for calling a global function with example usage: add_spikes_asymmetric(ts, xi) and returns: ts