class_docstr: Test cases for stateless random-number generator operators.
class_docstr_tok: ["Test","cases","for","stateless","random-number","generator","operators","."]
docstr: Tests whole-function forced-compilation.
  
  This test checks that stateless_random_* can be used in forced-compilation
  scenarios (e.g. TPU). The new version of stateless_random_* requires the
  intermediate tensor `alg` to be compile-time constant, so we need to check
  that this requirement won't prevent `seed` from depending on variables.
docstr_tok: ["Tests","whole-function","forced-compilation",".","This","test","checks","that","stateless_random_","*","can","be","used","in","forced-compilation","scenarios","(","e.g",".","TPU",")",".","The","new","version","of","stateless_random_","*","requires","the","intermediate","tensor","`","alg","`","to","be","compile-time","constant",",","so","we","need","to","check","that","this","requirement","wo","n't","prevent","`","seed","`","from","depending","on","variables","."]
code: def testForcedCompile(self):
      """Tests whole-function forced-compilation.
  
      This test checks that stateless_random_* can be used in forced-compilation
      scenarios (e.g. TPU). The new version of stateless_random_* requires the
      intermediate tensor `alg` to be compile-time constant, so we need to check
      that this requirement won't prevent `seed` from depending on variables.
      """
      if config.list_logical_devices("TPU"):
          self.skipTest(
              "To accommodate OSS, experimental_compile support for TPU "
              "is not linked in."
          )
      # GPU doesn't support int32 variables, so we use int64.
      v = variables.Variable([1, 2], dtype=dtypes.int64)
  
      @def_function.function(experimental_compile=True)
      def f():
          (
              key,
              counter,
          ) = gen_stateless_random_ops_v2.stateless_random_get_key_counter(
              seed=math_ops.cast(v.read_value(), dtypes.int32)
          )
          alg = gen_stateless_random_ops_v2.stateless_random_get_alg()
          return gen_stateless_random_ops_v2.stateless_random_normal_v2(
              shape=[], key=key, counter=counter, alg=alg
          )
  
      f()
  
imports: import functools
  import os
  from absl.testing import parameterized
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.client import device_lib
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import config
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.random import util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_stateless_random_ops_v2
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops_util
  from tensorflow.python.ops import stateless_random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling the StatelessRandomOpsTest obj's underlying member method code with example usage: obj.testForcedCompile() and returns: gen_stateless_random_ops_v2