<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rollback(self):
 """Roll back a transaction on the database."""

        self._check_state()
        database = self._session._database
        api = database.spanner_api
        metadata = _metadata_with_prefix(database.name)
        api.rollback(self._session.name, self._transaction_id, metadata=metadata)
        self._rolled_back = True
        del self._session._transaction