Much of what you are asking is dependent on the data you have (not just it’s type, but it’s sparseness and length) and on the needs of your visualization.
Given that you have reduced it to these 2 options (why? maybe you want to use an external tool, so another option would be - torchvision.utils.save_image and export it to that handler) I can only say that the fact you are using cmap=‘gray’ in the second option, means that you don’t have an RGB(A) format of the data and that you are doing some transformation (or conversion) to the data on the second option as well(from the documentation: “The Colormap instance or registered colormap name used to map scalar data to colors”).