During the Ming and Qing dynasties, eunuchs generally signed up for the palace first, and then purified themselves. This is because in the Ming and Qing dynasties, the rule of entering the palace to be clean has been gradually abolished. The selection of eunuchs is mainly through the imperial examination or the establishment of relations with court officials to get opportunities, and then enter the court for examination and training. Eunuchs need to serve the emperor and queen in the court and perform some important tasks, so they need to receive strict training and examination.
However, in the Tang and Song Dynasties, the procedure of selecting eunuchs to enter the palace was usually to clean up before signing up for the palace. This is because in the Tang and Song Dynasties, eunuchs had a relatively low status and were considered as "slaves". They were not allowed to take the imperial examinations or establish relations with court officials. Therefore, they need to have a physical examination and a clean body first, and then be selected by officials appointed by the court before they can enter the court to serve the emperor.
In short, different dynasties and historical periods have different procedures for selecting eunuchs to enter the palace, but they usually need strict training and assessment to ensure that they can be competent for the work in the palace.