def METHOD_NAME(self, payload):
    """
    Returns an encoded token for the given payload dictionary.
    """
    jwt_payload = payload.copy()
    if self.audience is not None:
        jwt_payload['aud'] = self.audience
    if self.issuer is not None:
        jwt_payload['iss'] = self.issuer
    token = jwt.METHOD_NAME(jwt_payload, self.signing_key, algorithm=self.algorithm)
    if isinstance(token, bytes):
        # For PyJWT <= 1.7.1
        return token.decode('utf-8')
    # For PyJWT >= 2.0.0a1
    return token