import math


def borders_ms_to_frames(borders, rate):
    """
    Function to convert a list of 2-item lists or tuples from milliseconds to
    frames.

    Parameters
    ----------
    borders : list
        a list of 2-item lists or tuples, each item of which is a number of
        milliseconds

    rate : float
        frames per millisecond (fps / 1000)

    Returns
    -------
    frame_borders : list
        a list of 2-item lists or tuples, each item of which is a number of
        frames
    """
    frame_borders = []
    for start, stop in borders:
        frame_borders.append((math.floor(start * rate), math.ceil(stop *
                             rate)))
    return frame_borders