def begin_transaction(self):
        """ Should be called before the start of each new transaction.

        Note that prior to the first invocation of this method,
        you must invoke `init_transactions()` exactly one time.

        Raises:
            ProducerFencedError if another producer is with the same
                transactional_id is active.
        """
        # Set the transactional bit in the producer.
        if not self._transaction_manager:
            raise Errors.IllegalStateError("Cannot use transactional methods without enabling transactions")
        self._transaction_manager.begin_transaction()
 Should be called before the start of each new transaction.

        Note that prior to the first invocation of this method,
        you must invoke `init_transactions()` exactly one time.

        Raises:
            ProducerFencedError if another producer is with the same
                transactional_id is active.
        
kafka/producer/kafka.py