Just for your reference and anyone finding this, I have what I believe are Gen 4 tags. I successfully flashed and the AMS recognizes it.
hf mf info gives me the following output, which I don't think your script covers as a successful Gen 4 find:
[usb] pm3 --> hf mf info
[=] --- ISO14443-a Information ---------------------
[+] UID: AA 55 C3 96
[+] ATQA: 00 04
[+] SAK: 08 [2]
[=] --- Keys Information
[+] loaded 2 user keys
[+] loaded 61 hardcoded keys
[+] Sector 0 key A... FFFFFFFFFFFF
[+] Sector 0 key B... FFFFFFFFFFFF
[+] Sector 1 key A... FFFFFFFFFFFF
[+] Block 0.... AA55C396AA0804000000000000000000 | ........
[=] --- Fingerprint
[+] unknown
[=] --- Magic Tag Information
[+] Magic capabilities... Gen 2 / CUID
[+] Magic capabilities... Write Once / FUID
[=] --- PRNG Information
[+] Prng....... weak

Just for your reference and anyone finding this, I have what I believe are Gen 4 tags. I successfully flashed and the AMS recognizes it.
hf mf infogives me the following output, which I don't think your script covers as a successful Gen 4 find: