How to save tensors to a JPEG file for 85 images

I have a tensor of 85 images and size as (1 , 1024 , 1024 ,1)

How can I convert this tensor of 85 images and save as a JPEG file.

I was able to view the images by the below code but how do I save it in loop for 85 images ?

all_last_activations.shape
output : ( 85 , 1 , 1024 , 1024 ,1)

#tensor of 54th image
z = all_last_activations[54]
z.shape
output : ( 1 , 1024 , 1024 ,1)

#displaying the 54th image
arr_ = np.squeeze(z)
plt.imshow(arr_)
plt.show()

You can use tf.keras.utils.save_img. But your images have just one color channel. If you want to save them in jpg format, you should use tf.image.grayscale_to_rgb first.