Firstly, the comment mentioned by @Medi1Saif (namely: "How else would you study medicine?" looks profitable; and might be a solver approach.
Secondly, regarding the last part of your question, I'm not certain but think that: it would be permissible in necessary situation -- without Reibeh (the risk of sin ...) or enjoyment ...
Thirdly, in regards to your initial query, I found roughly a similar question-answer, which might help you to some extent, which is as follows: (Based on the Fatwa of Ayatollah Makarem-Shirazi):
Question: What's the Hokm of looking at the unclothes photos in medical books, whose instruction is necessary for the students (of university) and is occasionally with Reibeh (fear of doing haram practice)
Answer: It is permissible without the intention of enjoyment and Reibeh, and only (can) see in necessary items and in a needed quantity whenever such state is gotten spontaneously.