The New Republic uses a machine to carry out electro-shock therapy on Dr. Pershing and he refers to it as Mind Flayer, a device that has been mentioned once before in The Mandalorian.
Elia Kane convinces Dr. Pershing that he must continue his research because it will be hugely beneficial to the New Republic but she betrays him and turns him over to the officers and accuses him of being a traitor.
For his punishment, Dr. Pershing is connected to a machine that a technician mentions has been approved for the rehabilitation of amnesty program members and calls it a 602 Mitigator.
Dr. Pershing calls it a Mind Flayer meant to wipe his memories but the technician insists that it’s a similar device that operates on a low voltage to soothe an individual’s traumatic memories through electro-shock therapy.
They set it up but after everyone leaves the room, Elia raises the voltage of the machine to scramble Pershing’s brain and wipe all of his memories of the Empire and his time with Moff Gideon.
The “Mind Flayer” has been mentioned only once before, in season 1 of The Mandalorian when Cara Dune claims that if she surrendered to the Empire, she would be “uploaded to a Mind Flayer” but Greef Karga tells her that the Mind Flayer is just a lie told to instill fear.
In the Rogue One film, Saw Guerrera tortures Bodhi Rook with a creature named Bor Gullet that probes into his mind and manipulates his thoughts, driving him mad in the process. The creature is called a Mairan in the comic Doctor Aphra #21.
In that story, it is shown that the Empire kept three cryogenically frozen Mairan in case they wanted to use them and these creatures’ abilities and appearance closely resemble that of a Mind Flayer, leading to the plausible comparison.