class_docstr: Tests for batch_ops.{un,}batch.
class_docstr_tok: ["Tests","for","batch_ops",".","{","un",",","}","batch","."]
docstr: Tests that batch_function op works with captured input.
docstr_tok: ["Tests","that","batch_function","op","works","with","captured","input","."]
code: def testBatchFunctionOpWithCapturedInput(self):
      """Tests that batch_function op works with captured input."""
      if context.executing_eagerly():
          return
      with self.cached_session() as sess:
          captured_inp0 = array_ops.placeholder_with_default(
              2, shape=[]
          )
          captured_inp1 = array_ops.placeholder_with_default(
              1, shape=[]
          )
          inp = array_ops.placeholder(dtype=dtypes.int32, shape=[1])
  
          @function.Defun(dtypes.int32)
          def computation(inp):
              return inp + captured_inp0 - captured_inp1
  
          result = gen_batch_ops.batch_function(
              num_batch_threads=1,
              max_batch_size=10,
              batch_timeout_micros=100000,  # 100ms
              allowed_batch_sizes=[3, 10],
              batching_queue="",
              f=computation,
              in_tensors=[inp],
              captured_tensors=computation.captured_inputs,
              Tout=[
                  o.type
                  for o in computation.definition.signature.output_arg
              ],
          )
  
          thread_results = []
  
          def worker():
              thread_results.extend(
                  sess.run([result], feed_dict={inp: [1]})
              )
  
          worker_thread = threading.Thread(target=worker)
          worker_thread.start()
          main_results = sess.run([result], feed_dict={inp: [2]})
          worker_thread.join()
          self.assertEqual(thread_results[0], [2])
          self.assertEqual(main_results[0], [3])
  
imports: import threading
  import time
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import function
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.framework.errors import InvalidArgumentError
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import batch_ops
  from tensorflow.python.ops import gen_batch_ops
  from tensorflow.python.ops import gen_functional_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 13 for calling the BatchOpsTest obj's underlying member method code with example usage: obj.testBatchFunctionOpWithCapturedInput() and returns: unknown