No. 502 is a robot who had Professor Hayase’s body.
Hayase (No. 502) wanted to give Fuyou, Hayase’s daughter, a lot more friends. Hayase also conducted an experiment to fuse Fuyou’s body inside Tamas (No.0 at the time), but that ended up killing Fuyou in the process. No. 502, while not having a soul implanted into him, was working alongside another person willing to takeover the Fuyou Project along with another pink-haired robot maid. At that moment when Tama showed Gintoki & Kagura the body of Professor Hayase, Hayase began to creep up near the head of Tama and began to fuse his own body into No. 502’s.
When No. 502 retrieved the head of Tama, the seed was missing from Tama. To retrieve the seed back, he planned a hijack at the Terminal. The plan was nearly a big success and he was about to use Shinpachi as a test person until Gintoki tried to kill No. 502. It was later revealed that Professor Hayase was actually alone himself. After Fuyou and Gintoki explained that to him, No. 502 continued the hijack anyway and tried to kill both Shinpachi and Gintoki. Kagura and Gengai’s Robots, however, prevented No. 502 from killing Gintoki and Tama began to prevent No. 502 from running away. Gintoki, who would escape, would move No. 502 and Hayase’s soul into the power of the Terminal, thus eventually killing him.