def add_sample_weight(df_in, power_factor=1.5):
    """
    Add a column with weights for biased sampling towards places with a higher
    number of tokens.

    Parameters
    ----------
    df_in: DataFrame
        Input DataFrame with a "nr_tokens" column containing the number of
        tokens in a destination text.
    power_factor: float
        Value used for inflating the nr_tokens value to get to the desired
        sampling weight.

    Returns
    -------
    out: DataFrame
        DataFrame with a "weight" column containing the sampling weights.
    """
    return df_in.assign(
        weight=lambda df: (df["nr_tokens"] ** power_factor).astype(int)
    )