def transform_token_ids_to_sentences(y_ids, index_to_token):
    """
    Transforms batch of token ids into list of joined strings (sentences)
    Transformation of each sentence ends when the end_token occurred.
    Skips start tokens.

    :param y_ids: numpy array of integers, shape (lines_num, tokens_num), represents token ids
    :param index_to_token: dictionary to be used for transforming
    :return: list of strings, list length = lines_num
    """
    n_responses, n_tokens = y_ids.shape

    responses = []
    for resp_idx in range(n_responses):
        response_tokens = []
        for token_idx in range(n_tokens):
            token_to_add = index_to_token[y_ids[resp_idx, token_idx]]

            if token_to_add in [SPECIAL_TOKENS.EOS_TOKEN, SPECIAL_TOKENS.PAD_TOKEN]:
                break
            if token_to_add == SPECIAL_TOKENS.START_TOKEN:
                continue
            response_tokens.append(token_to_add)

        response_str = ' '.join(response_tokens)
        responses.append(response_str)
    return responses

    Transforms batch of token ids into list of joined strings (sentences)
    Transformation of each sentence ends when the end_token occurred.
    Skips start tokens.

    :param y_ids: numpy array of integers, shape (lines_num, tokens_num), represents token ids
    :param index_to_token: dictionary to be used for transforming
    :return: list of strings, list length = lines_num
    
cakechat/dialog_model/model_utils.py