def video_lisa_encode_multi_conv_fn(
        example,
        tokenizer,
        max_length,
        input_ids_with_output=True
):
    """We only support the following three scenarios:

    1. Incremental pretraining dataset.
        example['conversation'] = [
                {
                    'input': '',
                    'output': '### Human: Can you write xxx'
                }
            ]

    2. Single-turn conversation dataset.
        example['conversation'] = [
                {
                    'input': 'Give three tips for staying healthy.',
                    'output': '1.Eat a balanced diet xxx'
                }
            ]

    3. Multi-turn conversation dataset.
        example['conversation'] = [
                {
                    'input': 'Give three tips for staying healthy.',
                    'output': '1.Eat a balanced diet xxx'
                },
                {
                    'input': 'Please expand on the second point.',
                    'output': 'Here is an expanded explanation of the xxx'
                }
            ]
    """
    bos_token_id, eos_token_id = get_bos_eos_token_ids(tokenizer)
    assert not input_ids_with_output
    input_id_list = []
    for conv in example['conversation']:
        input_ids = []
        next_needs_bos_token = True
        for single_turn_conversation in conv:
            input = single_turn_conversation['input']
            input_encode = tokenizer.encode(input, add_special_tokens=False)
            if next_needs_bos_token:
                input_ids += bos_token_id
            input_ids += input_encode

        if len(input_ids) > max_length:
            input_ids = input_ids[:max_length]

        input_id_list.append(input_ids)
    return {'input_ids': input_id_list}
We only support the following three scenarios:

1. Incremental pretraining dataset.
example['conversation'] = [
{
'input': '',
'output': '### Human: Can you write xxx'
}
]

2. Single-turn conversation dataset.
example['conversation'] = [
{
'input': 'Give three tips for staying healthy.',
'output': '1.Eat a balanced diet xxx'
}
]

3. Multi-turn conversation dataset.
example['conversation'] = [
{
'input': 'Give three tips for staying healthy.',
'output': '1.Eat a balanced diet xxx'
},
{
'input': 'Please expand on the second point.',
'output': 'Here is an expanded explanation of the xxx'
}
]
projects/llava_sam2/datasets/encode_fn.py