class_docstr: Tests for batch_ops.{un,}batch.
class_docstr_tok: ["Tests","for","batch_ops",".","{","un",",","}","batch","."]
code: def testParallelRunsWithCpuAndGpu(self):
      # Run multiple instances of a batch function in parallel. This is a
      # regression test: this used to fail because _Send nodes for one call would
      # send the tensor to the _Recv node for a different call.
      if context.executing_eagerly():
          return
  
      @batch_ops.batch_function(1, 2, 1)
      def f(x):
          with ops.device("/GPU:0"):
              x = x + 1.0
          with ops.device("/CPU:0"):
              return x + 1
  
      num_calls = 10
      placeholders = [
          array_ops.placeholder(dtypes.float32, shape=(1,))
          for _ in range(num_calls)
      ]
      results = []
      for p in placeholders:
          result = f(p)
          results.append(result)
      inputs = [[float(i)] for i in range(num_calls)]
      expected = [[float(i + 2)] for i in range(num_calls)]
      with self.session() as sess:
          outputs = sess.run(
              results, feed_dict=dict(zip(placeholders, inputs))
          )
          self.assertAllEqual(outputs, expected)
  
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 10 for calling the BatchOpsTest obj's underlying member method code with example usage: obj.testParallelRunsWithCpuAndGpu() and returns: unknown