class_docstr: Tests for batch_ops.{un,}batch.
class_docstr_tok: ["Tests","for","batch_ops",".","{","un",",","}","batch","."]
code: def testBatchDecoratedGpu(self):
      if context.executing_eagerly():
          return
      with self.cached_session() as sess:
  
          @batch_ops.batch_function(1, 10, 100000)
          def computation(in_t):
              # index is 0 on CPU and 1 on GPU
              index = gen_functional_ops.DeviceIndex(
                  device_names=["CPU", "GPU"]
              )
              return in_t + math_ops.cast(index, dtypes.float32)
  
          inp = array_ops.placeholder(dtype=dtypes.float32, shape=[1])
          result = computation(inp)
          thread_results = []
  
          def worker():
              thread_results.extend(
                  sess.run([result], feed_dict={inp: [10.0]})
              )
  
          worker_thread = threading.Thread(target=worker)
          worker_thread.start()
          main_results = sess.run([result], feed_dict={inp: [20.0]})
          worker_thread.join()
          self.assertEqual(
              thread_results[0], [10 + test_util.is_gpu_available()]
          )
          self.assertEqual(
              main_results[0], [20 + test_util.is_gpu_available()]
          )
  
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 9 for calling the BatchOpsTest obj's underlying member method code with example usage: obj.testBatchDecoratedGpu() and returns: unknown