import torch


def frame_signal(signal, frame_size):
    """
    cut signal into nonoverlapping frames
    Args:
        signal: [batch, n_samples]
        frame_size: int 
    Returns:
        [batch, n_frames, frame_size]
    """
    signal_len = signal.shape[-1]
    padding = (frame_size - (signal_len % frame_size) ) % frame_size
    signal = torch.nn.functional.pad(signal, (0, padding), 'constant', 0)
    frames = torch.split(signal.unsqueeze(1), frame_size, dim=-1)
    return torch.cat(frames, dim=1)