# Codeblock 24 def inference(): denoised_images = [] #(1) with torch.no_grad(): #(2) current_prediction = torch.randn((64, NUM_CHANNELS, IMAGE_SIZE, IMAGE_SIZE)).to(DEVICE) #(3) for i in tqdm(reversed(range(NUM_TIMESTEPS))): #(4) predicted_noise = model(current_prediction, torch.as_tensor(i).unsqueeze(0)) #(5) current_prediction, denoised_image = noise_scheduler.backward_diffusion(current_prediction, predicted_noise, torch.as_tensor(i)) #(6) if i%100 == 0: #(7) denoised_images.append(denoised_image) return denoised_images