def generate():
    """returns a list of zipped inputs, outputs and number of new tokens"""

    if model_type == "git":
        input_tokens = tokenizer(images=inputs, return_tensors="pt")
        input_ids = input_tokens.pixel_values
    elif model_type == "llava":
        input_ids = torch.stack(
            [
                tokenizer_image_token(
                    pmt, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt"
                )
                for pmt in inputs
            ]
        )
        image_tensor = [
            image_processor.preprocess(img, return_tensors="pt")["pixel_values"].to(
                infer_dtype
            )
            for img in image
        ]
        input_tokens = {"input_ids": input_ids, "images": image_tensor}
    elif model_type == "whisper":
        input_tokens = tokenizer(inputs, sampling_rate=16000, return_tensors="pt")
        input_ids = input_tokens.input_features
    elif model_type == "mllama":
        raw_image = load_image(args.image_url)
        raw_image = [raw_image] * args.batch_size
        input_tokens = tokenizer(raw_image, prompt, return_tensors="pt")
        input_ids = input_tokens["input_ids"]
    elif model_type == "maira2":
        input_tokens = process_input_func(
            current_frontal=sample,
            current_lateral=None,
            prior_frontal=None,
            indication=None,
            technique=None,
            comparison=None,
            prior_report=None,
            return_tensors="pt",
            get_grounding=False,
        )
        input_ids = input_tokens["input_ids"]
    elif model_type == "phi4mm":
        raw_image = load_image(args.image_url) if is_vision else None
        raw_image = [raw_image] * args.batch_size
        samples = [sample] * audio_batch_size
        input_tokens = tokenizer(
            text=inputs[0],
            images=raw_image if is_vision else None,
            audios=samples if is_speech else None,
            return_tensors="pt",
        )
        input_ids = input_tokens["input_ids"]
    else:
        input_tokens = tokenizer.batch_encode_plus(
            inputs, return_token_type_ids=False, return_tensors="pt"
        )
        input_ids = input_tokens.input_ids
    for t in input_tokens:
        if torch.is_tensor(input_tokens[t]):
            input_tokens[t] = input_tokens[t].to(
                get_accelerator().current_device_name()
            )
    with torch.inference_mode(), torch.no_grad(), torch.cpu.amp.autocast(
        enabled=True if infer_dtype in [torch.bfloat16, torch.float16] else False
    ):
        outputs = model.generate(**input_tokens, **generate_kwargs)
    gen_ids = outputs[0] if args.token_latency else outputs

    input_tokens_lengths = [x.shape[0] for x in input_ids]
    output_tokens_lengths = [x.shape[0] for x in gen_ids]

    total_new_tokens = [
        o if model.config.model_type in ["t5", "whisper"] else o - i
        for i, o in zip(input_tokens_lengths, output_tokens_lengths)
    ]
    gen_text = tokenizer.batch_decode(
        (
            gen_ids[:, input_ids.shape[1] :]
            if model_type in ["llava", "maira2", "phi4mm"]
            else gen_ids
        ),
        skip_special_tokens=True,
    )

    return zip(inputs, gen_text, total_new_tokens), outputs
returns a list of zipped inputs, outputs and number of new tokens
examples/cpu/llm/inference/distributed/run_generation_with_deepspeed.py