code: def sign_compact(self, keys=None, protected=None, **kwargs):
          
  
          _headers = self._header
          _headers.update(kwargs)
  
          key, xargs, _alg = self.alg_keys(keys, 'sig', protected)
  
          if "typ" in self:
              xargs["typ"] = self["typ"]
  
          _headers.update(xargs)
          jwt = JWSig(**_headers)
          if _alg == "none":
              return jwt.pack(parts=[self.msg, ""])
  
          # All other cases
          try:
              _signer = SIGNER_ALGS[_alg]
          except KeyError:
              raise UnknownAlgorithm(_alg)
  
          _input = jwt.pack(parts=[self.msg])
  
          if isinstance(key, AsymmetricKey):
              sig = _signer.sign(_input.encode("utf-8"), key.private_key())
          else:
              sig = _signer.sign(_input.encode("utf-8"), key.key)
  
          logger.debug("Signed message using key with kid=%s" % key.kid)
          return ".".join([_input, b64encode_item(sig).decode("utf-8")])
docs: Produce a JWS using the JWS Compact Serialization
  
          :param keys: A dictionary of keys
          :param protected: The protected headers (a dictionary)
          :param kwargs: claims you want to add to the standard headers
          :return: A signed JSON Web Token