import warnings


def sample_frames(steps, max_frames):
    """Sample uniformly from given list of frames.

    Args:
        steps: The frames to sample from.
        max_frames: Maximum number of frames to sample.

    Returns:
        The list of sampled frames.
    """
    samples = []
    steps_len = len(steps)
    if max_frames > steps_len:
        warnings.warn(
            f"Less than {max_frames} frames provided, producing {steps_len} frames."
        )
        max_frames = steps_len
    interval = steps_len // max_frames
    counter = 0
    for i in range(steps_len - 1, -1, -1):  # Sample from the end
        if i % interval == 0 and counter < max_frames:
            samples.append(steps[i])
            counter += 1
    return list(reversed(samples))