def t2i(model, image_size, prompt, uc, sampler, step=20, scale=7.5, batch_size=8, ddim_eta=0., dtype=torch.float32, device="cuda", camera=None, num_frames=1):
    '''
        model, args.size,   t,     uc, sampler, step=50, scale=10,  batch_size=batch_size, ddim_eta=0.0, dtype=dtype, device=device, camera=camera, num_frames=args.num_frames
    '''
    # ---------------------------------------------------------
    # step 1 : pormpt
    if type(prompt)!=list:
        prompt = [prompt]
    
    # ---------------------------------------------------------
    # step 2 : infer
    with torch.no_grad(), torch.autocast(device_type=device, dtype=dtype):
        # ---------------------------------------------------------
        # step 2.1 : context
        c = model.get_learned_conditioning(prompt).to(device)
        c_ = {"context": c.repeat(batch_size,1,1)}
        uc_ = {"context": uc.repeat(batch_size,1,1)}
        if camera is not None:
            c_["camera"] = uc_["camera"] = camera
            c_["num_frames"] = uc_["num_frames"] = num_frames

        # ---------------------------------------------------------
        # step 2.2 : sample
        shape = [4, image_size // 8, image_size // 8]
        samples_ddim, _ = sampler.sample(S=step, conditioning=c_,
                                        batch_size=batch_size, shape=shape,
                                        verbose=False, 
                                        unconditional_guidance_scale=scale,
                                        unconditional_conditioning=uc_,
                                        eta=ddim_eta, x_T=None)
        
        # ---------------------------------------------------------
        # step 2.3 : decode
        x_sample = model.decode_first_stage(samples_ddim)

        # ---------------------------------------------------------
        # step 2.4 : norm 
        x_sample = torch.clamp((x_sample + 1.0) / 2.0, min=0.0, max=1.0)
        x_sample = 255. * x_sample.permute(0,2,3,1).cpu().numpy()

    return list(x_sample.astype(np.uint8))

        model, args.size,   t,     uc, sampler, step=50, scale=10,  batch_size=batch_size, ddim_eta=0.0, dtype=dtype, device=device, camera=camera, num_frames=args.num_frames
    
mv-diffusion/MVDream/t2i_single.py