import tensorflow as tf

    with self.test_session() as session:

      @dynamic_batching.batch_fn
      def f(a, b):
        return a + b

      output0 = f(tf.constant([1]), tf.constant([2]))
      output1 = f(tf.constant([[2]]), tf.constant([3]))

      tp = pool.ThreadPool(2)
      f0 = tp.apply_async(session.run, [output0])
      f1 = tp.apply_async(session.run, [output1])

      time.sleep(_SLEEP_TIME)

      coord = tf.train.Coordinator()
      tf.train.start_queue_runners(coord=coord)

      with self.assertRaises(tf.errors.CancelledError):
        f0.get()
        f1.get()

      with self.assertRaisesRegexp(tf.errors.InvalidArgumentError,
                                   'Shapes of inputs much be equal'):
        coord.join()

  def test_output_must_have_batch_dimension(self):
    with self.test_session() as session:
      @dynamic_batching.batch_fn
      def f(_):
