def remove_short_segments(
    lbl_tb, segment_inds_list, timebin_dur, min_segment_dur, unlabeled_label=0
):
    """remove segments from vector of labeled timebins
    that are shorter than specified duration

    Parameters
    ----------
    lbl_tb : numpy.ndarray
        vector of labeled spectrogram time bins, i.e.,
        where each element is a label for a time bin.
        Output of a neural network.
    segment_inds_list : list
        of numpy.ndarray, indices that will recover segments list from lbl_tb.
        Returned by funciton ``vak.labels.lbl_tb_segment_inds_list``.
    timebin_dur : float
        Duration of a single timebin in the spectrogram, in seconds.
        Used to convert onset and offset indices in lbl_tb to seconds.
    min_segment_dur : float
        minimum duration of segment, in seconds. If specified, then
        any segment with a duration less than min_segment_dur is
        removed from lbl_tb. Default is None, in which case no
        segments are removed.
    unlabeled_label : int
        label that was given to segments that were not labeled in annotation,
        e.g. silent periods between annotated segments. Default is 0.

    Returns
    -------
    lbl_tb : numpy.ndarray
        with segments removed whose duration is shorter than min_segment_dur
    segment_inds_list : list
        of numpy.ndarray, with arrays popped off that correspond
        to segments removed from lbl_tb
    """
    to_pop = []

    for segment_inds in segment_inds_list:
        if segment_inds.shape[-1] * timebin_dur < min_segment_dur:
            lbl_tb[segment_inds] = unlabeled_label

    if to_pop:
        for seg_inds in to_pop:
            segment_inds_list.remove(seg_inds)

    return lbl_tb, segment_inds_list