code: def begin(self):
          
          if self._transaction_id is not None:
              raise ValueError("Transaction already begun")
  
          if self.committed is not None:
              raise ValueError("Transaction already committed")
  
          if self._rolled_back:
              raise ValueError("Transaction is already rolled back")
  
          database = self._session._database
          api = database.spanner_api
          metadata = _metadata_with_prefix(database.name)
          txn_options = TransactionOptions(read_write=TransactionOptions.ReadWrite())
          response = api.begin_transaction(
              self._session.name, txn_options, metadata=metadata
          )
          self._transaction_id = response.id
          return self._transaction_id
docs: Begin a transaction on the database.
  
          :rtype: bytes
          :returns: the ID for the newly-begun transaction.
          :raises ValueError:
              if the transaction is already begun, committed, or rolled back.