<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_token(self, auth, name, username=None):
 """ Creates a new token with the specified name for the specified user. If no user is specified, uses user authenticated by ``auth``. :param auth.Authentication auth: authentication for user to retrieve. Must be a username-password authentication, due to a restriction of the Gogs API :param str name: name of new token :param str username: username of owner of new token :return: new token representation :rtype: Token :raises NetworkFailure: if there is an error communicating with the server :raises ApiFailure: if the request cannot be serviced """

        if username is None:
            username = self.authenticated_user(auth).username
        data = {"name": name}
        response = self.post("/users/{u}/tokens".format(u=username), auth=auth, data=data)
        return Token.from_json(response.json())