def _extract_dataset_from_db(force_sets_in_db, displacements_in_db, probs_in_db=None):
    """Collect force_sets, energies, and displacements to numpy arrays.

    Parameters
    ----------
    force_sets_in_db : List of ArrayData
        Each ArrayData is the output of PhonopyWorkChain.
    displacements_in_db : List of ArrayData
        Each ArrayData is the output of PhonopyWorkChain.
    probs_in_db : List of ArrayData or None
        Probability distributions of corresponding displacements and force constants.

    Returns
    -------
    my_force_sets : List of ndarray
    my_energies : List of ndarray
    my_displacements : List of ndarray

    """
    nitems = len(force_sets_in_db)
    my_displacements = []
    my_force_sets = []
    my_energies = []
    my_probs = []

    for i in range(nitems):
        force_sets = force_sets_in_db[i].get_array("force_sets")
        displacements = displacements_in_db[i].get_array("displacements")

        my_force_sets.append(force_sets)
        if "energies" in force_sets_in_db[i].get_arraynames():
            energy_sets = force_sets_in_db[i].get_array("energies")
            my_energies.append(energy_sets)
        my_displacements.append(displacements)

        if probs_in_db:
            my_probs.append(probs_in_db[i].get_array("probability_distributions"))

    return my_displacements, my_force_sets, my_energies, my_probs