Tennis star Nick Kyrgios pleaded guilty to assaulting a former girlfriend, but avoided a conviction for what the magistrate called a “single act of stupidity”.