def detokenize(x, tokenizer, as_lists = True):
    """
    Detokenize a given batch of sequences of tokens.
    x : int torch.tensors - shape (batch, seq_len)
    tokenizer : tokenizers.Tokenizer
    as_list : bool - return as list or string
    """
    if x.ndim == 1:
        x = x.unsqueeze(0)

    x = x.detach().cpu().tolist()
    x = tokenizer.decode_batch(x)

    if as_lists:
        return [s.split() for s in x]
    else:
        return x