How do I show a GIF of tensors converted into images?

I have a neural network whose goal is to create a small video. Each time i run the nn it return an image (tensor converted in image using plt.imgshow()), and i have to create a GIF using those images

You could store each image separately and use an external program to create the GIF or use OpenCV (or another lib) in Python.
This StackOverflow thread has some suggestions.