def to_str(l, rdic, char=False):
    """Given a sequence of indices, returns the corresponding string
    
    Arguments:
        l {list} -- List of indices
        rdic {dict} -- Dictionary mapping indices to strings
    
    Keyword Arguments:
        char {bool} -- Controls whether to add a whitespace between each token (default: {False})
    
    Returns:
        str -- Corresponding string
    """
    if char:
        sent = ''.join([rdic[i] for i in l])
    else:
        sent = ' '.join([rdic[i] for i in l])
    if sent[-4:] == '</s>':
        sent = sent[:-4]
    return sent