<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def HMAC(self, message, use_sha256=False):
 """Calculates the HMAC for a given message."""

    h = self._NewHMAC(use_sha256=use_sha256)
    h.update(message)
    return h.finalize()