def check_history(model, history):
    """Check if model was trained with different history to avoid key errors."""
    if not model.get('~'*history):
        history = len([c for c in model if c.startswith('~') and c.endswith('~')][0])
        print('#'* 57)
        print("# WARNING: the model was trained with history length:{0} #".format(history))
        print("#         Falling back to model history length.         #")
        print('#', ' '*53, '#')
        print('#'*22, 'GENERATING!', '#'*22)
    return history