Here are the main arguments scholars would use:
1- The medical field is a necessity in our society. We need medical doctors, and sometimes they need to be trained in examining the opposite gender since there are some differences between men and women when it comes to medical issues, and doctors ought to know that. Yes if it’s a sensitive examination, such as gynecology examinations, many scholars have said it’s haram for a male to go into that field (unless there is a shortage of females and it is a necessity then men enter this specialty).
2- We have hadiths in which the Imam (a) was asked about a woman who needs a medical procedure, and she wants a male doctor to perform it not a female doctor (since the male was more experienced). The Imam allowed it. So we can conclude from such hadiths that the opposite gender can be examined for the purpose of training.