code: def from_string(cls, key, key_id=None):
          
          key = _helpers.from_bytes(key)  # PEM expects str in Python 3
          marker_id, key_bytes = pem.readPemBlocksFromFile(
              six.StringIO(key), _PKCS1_MARKER, _PKCS8_MARKER)
  
          # Key is in pkcs1 format.
          if marker_id == 0:
              private_key = rsa.key.PrivateKey.load_pkcs1(
                  key_bytes, format='DER')
          # Key is in pkcs8.
          elif marker_id == 1:
              key_info, remaining = decoder.decode(
                  key_bytes, asn1Spec=_PKCS8_SPEC)
              if remaining != b'':
                  raise ValueError('Unused bytes', remaining)
              private_key_info = key_info.getComponentByName('privateKey')
              private_key = rsa.key.PrivateKey.load_pkcs1(
                  private_key_info.asOctets(), format='DER')
          else:
              raise ValueError('No key could be detected.')
  
          return cls(private_key, key_id=key_id)
docs: Construct an Signer instance from a private key in PEM format.
  
          Args:
              key (str): Private key in PEM format.
              key_id (str): An optional key id used to identify the private key.
  
          Returns:
              google.auth.crypt.Signer: The constructed signer.
  
          Raises:
              ValueError: If the key cannot be parsed as PKCS#1 or PKCS#8 in
                  PEM format.