There is no authority to declare or consider an elected and generally accepted Pope as an invalid Pope. The constant practice of the Church makes it evident that even in the case of an invalid election this invalid election will be de facto healed through the general acceptance of the new elected by the overwhelming majority of the cardinals and bishops.
Source, in full
Even in the case of a heretical pope he will not lose his office automatically and there is no body within the Church to declare him deposed because of heresy. Such actions would come close to a kind of a heresy of conciliarism or episcopalism. The heresy of conciliarism or episcopalism says basically that there is a body within the Church (Ecumenical Council, Synod, College of Cardinals, College of Bishops), which can issue a legally binding judgment over the Pope.
Notes from Wikiquote
The theory of the automatic loss of the papacy due to heresy remains only an opinion, and even St. Robert Bellarmin noticed this and did not present it as a teaching of the Magisterium itself. The perennial papal Magisterium never taught such an option. In 1917, when the Code of Canon Law (Codex Iuris Canonici) came into force, the Magisterium of the Church eliminated from the new legislation the remark of the Decretum Gratiani in the old Corpus Iuris Canonici, which stated, that a Pope, who deviates from right doctrine, can be deposed. | Never in history the Magisterium of the Church did admit any canonical procedures of deposition of a heretical pope. | From a letter of Athanasius Schneider regarding the About the Validity of the Pontificate of Pope Francis (September 18, 2023)