def get_processes(data, phases, train=True):
    """Get the processes for which certain phases are present. For train
    processes, the provided phases must be a subset of the present phases;
    for the test set, the provided and present phases must exactly match.

    Parameters
    ----------
    - data: pd.DataFrame
        the raw data 
    - phases: array-like
        the phases that (at least) need to be present in the data
    -train: bool
        whether or not we must extract processes from the training or 
        testing data
    
    Returns
    -------
    - filtered_processes: array-like

    """
    filtered_processes = []
    phases = set(phases)
    processes = set(data['process_id'])
    for process in processes:
        process_phases = set(data[data['process_id'] == process]['phase'])
        if train:
            if phases.issubset(process_phases):
                filtered_processes.append(process)
        else:
            if len(phases) == len(process_phases) == len(phases.intersection(process_phases)):
                filtered_processes.append(process)
    return filtered_processes