If an item is swapped/removed/whatever in a battle
If it's a PvP battle or a Trainer battle
Every Pokémon that has its item removed gets its original item back
If it's a Wild battle
If a Pokémon that had its original item removed is holding
a different item (because of the attack Trick for example)
The Pokémon keeps the new item and the original item is added to
the inventory.