(cands, num)
return rand_cands
Args:
        cands (List[obj])
        num (int or float)

    Returns:
        List[obj]
Args:
        cands (List[obj])
        num (int or float)
Args : cands ( List [ obj ] ) num ( int or float )
def _select_random_candidates(cands, num):
    """
    Args:
        cands (List[obj])
        num (int or float)

    Returns:
        List[obj]
    """
    if isinstance(num, int) and num >= 0:
        rand_cands = random.sample(cands, min(num, len(cands)))
    elif isinstance(num, float) and 0.0 <= num <= 1.0:
        rand_cands = [cand for cand in cands if random.random() < num]
    else:
        raise ValueError(
            f"num={num} is invalid; must be an int >= 0 or a float in [0.0, 1.0]"
        )
    return rand_cands
def _select_random_candidates ( cands , num ) : if isinstance ( num , int ) and num >= 0 : rand_cands = random . sample ( cands , min ( num , len ( cands ) ) ) elif isinstance ( num , float ) and 0.0 <= num <= 1.0 : rand_cands = [ cand for cand in cands if random . random ( ) < num ] else : raise ValueError ( f"num={num} is invalid; must be an int >= 0 or a float in [0.0, 1.0]" ) return rand_cands