def METHOD_NAME(ts: torch.Tensor, only_upper_spikes: bool = False):
    """
    Adds spikes to 15% of the time series in the form of heavy-tailed
    (Generalized Pareto) realizations.
    Arguments:
        ts: time series
        only_upper_spikes: boolean to indicate upper-tailed or two-tailed spikes
    """
    num_spikes = int(0.15 * ts.shape[0])
    indices_for_gp_spikes = np.random.choice(
        np.arange(len(ts)), replace=False, size=num_spikes
    )
    spike_direction = np.random.choice([-1, 1], replace=True, size=num_spikes)
    if only_upper_spikes:
        spike_direction = np.ones_like(spike_direction)
    spikes = stats.genpareto(1 / 50).rvs(num_spikes) * spike_direction
    ts[indices_for_gp_spikes] += spikes
    return ts