def generate_mask(n_samples, bagging=True, random_generator=np.random):
    if bagging is True:
        indices = random_generator.randint(0, n_samples, size=n_samples)
        mask = np.bincount(indices, minlength=n_samples)
    elif isinstance(bagging, float):
        mask = random_generator.uniform(size=n_samples) > 1. - bagging
    elif bagging is False:
        mask = np.ones(n_samples, dtype='float')
    else:
        raise ValueError("something wrong was passed as bagging")
    return mask
bagging: float or bool (default=True), bagging usually
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/uboost.py/generate_mask