904 causing knocking noise?

I would have to suggest a trans pan and filter inspection, as well as flex plate bolts check.
That right there should tell a lot.
A trans that has been sitting for a long time very well could eat the pump on startup and that would show in the pan.
I have to agree that random coming and going of the knock and going away when in gear sounds like a flexplate, but the trans has obvious issue's also. ("in and out of gear")