def append_text_gen_input_ids(
    tokenized_inputs, input_ids, attention_mask, context: int = None, ignore_index=IGNORE_INDEX
):
    """Convert input_ids to inputs dict and append to tokenized_inputs."""
    inputs = {"input_ids": input_ids, "attention_mask": attention_mask}

    # create labels
    # target is not shifted by 1 since causal lm models shifts internally when computing loss
    inputs["labels"] = labels = input_ids.clone()
    # set context to ignore_index
    if context is not None:
        labels[:context] = ignore_index
    # set padding to ignore_index
    labels[attention_mask != 1] = ignore_index

    # add to list
    for k, v in inputs.items():
        tokenized_inputs[k].append(v)
Convert input_ids to inputs dict and append to tokenized_inputs.
olive/data/component/text_generation.py