If you would like to reproduce the input, out should already be the prediction.
I’m not familiar with your use case, so could you explain, what kind of input you are trying to reconstruct?
Currently, if seems as if you have some labels in your input, as you are using argmax on your output.