It's a simple stop valve for the cap breather. A ball bearing inside a little plastic holder and blocks off the vent when the bike is upside down. They have been known to fall to bits and the ball bearing rattles around at the bottom of the tank. It sounds like you have this problem.