def log_predictions(predictions_path,
                    contexts_token_ids,
                    nn_model,
                    prediction_modes,
                    output_seq_len=MAX_PREDICTIONS_LENGTH,
                    **kwargs):
    """
    Generate responses for provided contexts and save the results on the disk. For a given context
    several responses will be generated - one for each mode from the prediction_modes list.

    :param predictions_path: Generated responses will be saved to this file
    :param contexts_token_ids: contexts token ids, numpy array of shape (batch_size, context_len, INPUT_SEQUENCE_LENGTH)
    :param nn_model: instance of CakeChatModel class
    :param prediction_modes: See PREDICTION_MODES for available options
    :param output_seq_len: Max number of tokens in generated responses
    """
    _logger.info('Logging responses for test set')

    # Create all the directories for the prediction path in case they don't exist
    ensure_dir(os.path.dirname(predictions_path))

    _init_csv_writer(predictions_path, output_seq_len, nn_model.model_name)

    contexts = transform_context_token_ids_to_sentences(contexts_token_ids, nn_model.index_to_token)
    predictions_data = pd.DataFrame()
    predictions_data['contexts'] = contexts

    for prediction_mode in prediction_modes:
        predicted_responses = get_nn_responses(contexts_token_ids, nn_model, prediction_mode, **kwargs)
        # list of lists of strings, shape (contexts_num, 1)
        predicted_responses = [response[0] for response in predicted_responses]
        # list of strings, shape (contexts_num)
        predictions_data[prediction_mode] = predicted_responses

    predictions_data.to_csv(predictions_path, sep='\t', index=False, encoding='utf-8', mode='a', float_format='%.2f')

    _logger.info('Dumped {} predicted responses to {}'.format(len(contexts), predictions_path))

    Generate responses for provided contexts and save the results on the disk. For a given context
    several responses will be generated - one for each mode from the prediction_modes list.

    :param predictions_path: Generated responses will be saved to this file
    :param contexts_token_ids: contexts token ids, numpy array of shape (batch_size, context_len, INPUT_SEQUENCE_LENGTH)
    :param nn_model: instance of CakeChatModel class
    :param prediction_modes: See PREDICTION_MODES for available options
    :param output_seq_len: Max number of tokens in generated responses
    
cakechat/dialog_model/quality/logging.py