code: def distribute_from_split_pool(tx, fee):
      
  
      # calculate fees
      if fee == 'standard':
          # TODO: improve this
          # 1: the tx is not fully built out, so it will actually be larger than implied at this point
          # 2: recommended_fee_for_tx gives estimates that are too high
          fee = tx_fee.recommended_fee_for_tx(tx)
  
      zero_txs_out = [tx_out for tx_out in tx.txs_out if tx_out.coin_value == 0]
      zero_count = len(zero_txs_out)
      if zero_count > 0:
          total_coin_value = sum(spendable.coin_value for spendable in tx.unspents)
          coins_allocated = sum(tx_out.coin_value for tx_out in tx.txs_out) + fee
          remaining_coins = total_coin_value - coins_allocated
          if remaining_coins < 0:
              raise ValueError("insufficient inputs for outputs")
          if remaining_coins < zero_count:
              raise ValueError("not enough to pay nonzero amounts to at least one of the unspecified outputs")
          for value, tx_out in zip(split_with_remainder(remaining_coins, zero_count), zero_txs_out):
              tx_out.coin_value = value
      return zero_count
docs: :param tx: a transaction
      :param fee: integer, satoshi value to set aside for transaction fee
  
      This function looks at TxOut items of a transaction tx and
      and puts TxOut items with a coin value of zero into a "split pool".
      Funds not explicitly claimed by the fee or other TxOut items are
      shared as equally as possible among the split pool. If the amount
      to be split does not divide evenly, some of the earlier TxOut items
      will get an extra satoshi. This function modifies `tx` in place.