class_docstr: Tests for batch_ops.{un,}batch.
class_docstr_tok: ["Tests","for","batch_ops",".","{","un",",","}","batch","."]
docstr: Test that batching with padding up to an allowed batch size works.
docstr_tok: ["Test","that","batching","with","padding","up","to","an","allowed","batch","size","works","."]
code: def testBatchWithPadding(self):
      """Test that batching with padding up to an allowed batch size works."""
      if context.executing_eagerly():
          return
      with self.cached_session() as sess:
          inp = array_ops.placeholder(dtype=dtypes.int32, shape=[2])
          batched, index, _ = batch_ops.batch(
              [inp],
              num_batch_threads=1,
              max_batch_size=10,
              batch_timeout_micros=100000,  # 100ms
              allowed_batch_sizes=[5, 10],
              grad_timeout_micros=0,
              batching_queue="",
          )
          thread_results = []
  
          def worker():
              thread_results.extend(
                  sess.run([batched, index], feed_dict={inp: [1, 3]})
              )
  
          worker_thread = threading.Thread(target=worker)
          worker_thread.start()
          main_results = sess.run(
              [batched, index], feed_dict={inp: [2, 4]}
          )
          worker_thread.join()
  
          # At this point either the thread or the main did the batch and the other
          # should have empty results.
          if list(thread_results[0][0]):
              batch_t = thread_results[0][0]
          else:
              batch_t = main_results[0][0]
  
          # Check that the batch tensor incorporates the padding.
          self.assertEqual(len(batch_t), 5)
  
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 2 for calling the BatchOpsTest obj's underlying member method code with example usage: obj.testBatchWithPadding() without return types