class_docstr: Tests for batch_ops.{un,}batch.
class_docstr_tok: ["Tests","for","batch_ops",".","{","un",",","}","batch","."]
code: def testSoftPlacement(self):
      if context.executing_eagerly():
          return
  
      @batch_ops.batch_function(1, 10, 100000)
      def computation(in_t):
          with ops.device("/GPU:0"):
              return in_t + 1.0
  
      inp = array_ops.placeholder(dtype=dtypes.float32, shape=[1])
      result = computation(inp)
  
      # With soft placement, the function will run even without a GPU
      config = config_pb2.ConfigProto(allow_soft_placement=True)
      with self.session(config=config) as sess:
          sess.run([result], feed_dict={inp: [20.0]})
  
      # Without soft placement, the function fails without a GPU due to the
      # addition explicitly being placed on the GPU
      config.allow_soft_placement = False
      with self.session(config=config) as sess:
          if test_util.is_gpu_available():
              sess.run([result], feed_dict={inp: [20.0]})
          else:
              with self.assertRaisesRegex(
                  InvalidArgumentError,
                  "Cannot assign a device for operation",
              ):
                  sess.run([result], feed_dict={inp: [20.0]})
  
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 11 for calling the BatchOpsTest obj's underlying member method code with example usage: obj.testSoftPlacement() and returns: unknown