This is how Twilight resurrects Thunderwing goes in Out of Twilight's Head.
[We see Celestia, Luna, Starlight, Trixie, Thorax, and Discord groundbridge to the cooridinates of the location of the final battle with Thunderwing]
Princess Celestia: The location where Thunderwing was defeated.
Starlight Glimmer: Why would Twilight come here?
Trixie: How am I supposed to know?
Thorax: That question's on my mind too.
Discord: Don't look at me.
Princess Luna: I fear Thunderwing's mind is dominant, and clearly he came here for one purpose -- To use the Dark Energon to resurrect his own body.
Princess Celestia: I too fear that.
Starlight Glimmer: No. Twilight would never let him do that. Just like she didn't let Thunderwing hurt me, Trixie, Thorax, and Discord.
Discord: That is true.
Princess Celestia: I hope you're all right.
[Princess Celestia, Princess Luna, Starlight, Trixie, Thorax, and Discord then see Twilight using dark magic to attach one end of the Cortical Pyschic Patch to Thunderwing's head and the other end to her horn]
Starlight Glimmer: Celestia, don't hurt Twilight.
Trixie: Yes. Please don't harm the Princess.
Thorax: She's delicate.
Discord: Be careful.
Princess Celestia: That's not Twilight.
Princess Luna: That's Thunderwing.
Starlight Glimmer: No. It's Twilight. I'm sure.
Trixie: I too believe it's her!
Thorax: Me three!
Discord: Me four!
[Princess Celestia prepares to remove the patch from Thunderwing's head]
Princess Celestia: Farewell, Thunderwing.
[Twilight swats away Princess Celestia and Princess Luna]
Starlight Glimmer: Hey. Twilight, you have to fight it!
Twilight Sparkle: Guys, is that you?
Starlight Glimmer: Yes, Twilight.
Trixie: It's us.
Thorax: Your friends.
Discord: Starlight, Trixie, Discord and Thorax.
Thunderwing: [in Twilight's mind] Unbelievable!
[Twilight holds her head in pain and collaspes]
Starlight Glimmer: Twilight!
Twilight Sparkle: [with Thunderwing's voice] Twilight can't hear you anymore.
Starlight Glimmer: You get out of my teacher's body!
Thorax: Let her go!
Discord: Release her mind!
Twilight Sparkle: [with Thunderwing's voice] Oh I will get out of your beloved teacher's body, my dear Starlight Glimmer, after I resurrect my own body.
Starlight Glimmer: As much as I want you to leave Twilight's body, I can't let you go back to your own.
[Twilight walks over to Thunderwing's corpse and removes the cable from his chest and holds the Dark Energon shard up.]
Starlight Glimmer: No!
Trixie: No! Don't!
Discord: Don't do it!
[Twilight shoves the Dark Energon shard into Thunderwing's chest. Princess Celestia, Princess Luna, Starlight, Trixie, Thorax, and Discord watch in horror as the shard disappears into Thunderwing's chest, reviving him. Thunderwing's red eyes snap open. Changelings watch in amazement.]
Thunderwing: Unicron, your most loyal follower has returned.
[Thunderwing looks at Twilight]
Thunderwing: Finish these pests. I have my own extermination to perform.