The function of metaphor in the line from the passage above is to emphasize what he is about to go through. It's also to build suspense. Thank you for posting your question. I hope that this answer helped you. Let me know if you need more help.
Generalizing or inferring