Generalizable Skill Learning in Robotic Agents Using Transformer Models