<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sign_statement(self, statement, node_name, key=None, key_file=None, node_id=None, id_attr=''):
 """Sign a SAML statement. :param statement: The statement to be signed :param key: The key to be used for the signing, either this or :param key_file: The file where the key can be found :param node_id: :param id_attr: The attribute name for the identifier, normally one of 'id','Id' or 'ID' :return: The signed statement """

        if not id_attr:
            id_attr = self.id_attr

        if not key_file and key:
            _, key_file = make_temp(str(key).encode(), '.pem')

        if not key and not key_file:
            key_file = self.key_file

        return self.crypto.sign_statement(
                statement,
                node_name,
                key_file,
                node_id,
                id_attr)