import torch


def repeat_signal(signal, sig_len, required_length):
    """repeat signal to make short signal to have required_length
    Args:
        signal (FloatTensor): input signal
        sig_len (LongTensor): length of input signal
        required_length(float) : length of generated signal
    Returns:
        signal (FloatTensor): generated signal of required_length by repeating itself.
    """
    repeat = required_length // sig_len
    rem = required_length % sig_len
    sub = signal[-rem:] if rem > 0 else torch.tensor([])
    rep_sig = torch.cat(repeat * [signal])
    signal = torch.cat((rep_sig, sub))
    return signal