def text_generator(prompt, tokenizer, model, num_sequences=1, model_kwargs=None):
    """Generates text for a given prompt, tokenizer, and model

    Parameters
    ----------
    prompt : str
        prompt text
    tokenizer : transformers Tokenizer
        a transformers tokenizer
    model : transformers Model
        a transformers model    
    num_sequences : int
        the number of sequences to return for the input
    generate_kwargs : dict
        key words passed to a the text generator model 

    Returns
    -------
    str
        response text
    """
    inputs = tokenizer.encode(prompt, return_tensors='pt')
    # generate responses
    kwargs = {
        'max_length': max(30, len(inputs[0])+1),
        'do_sample': True,
        'top_p': .95
    }
    if model_kwargs is not None:
        kwargs.update(model_kwargs)
    kwargs['num_return_sequences'] = num_sequences
    outputs = model.generate(inputs, **kwargs)
    responses = [tokenizer.decode(o, skip_special_tokens=True)[
        len(prompt):] for o in outputs]
    return responses