Tennis star Nick Kyrgios has pleaded guilty to assaulting his ex-girlfriend, avoiding a criminal conviction in the process.