class_docstr: Test cases for stateful random-number generator operators.
class_docstr_tok: ["Test","cases","for","stateful","random-number","generator","operators","."]
docstr: Tests XLA and CPU kernels generate the same integers in overflow case.
  
  Specifically this tests the case where the counter is incremented past
  what can fit within 64 bits of the 128 bit Philox counter.
docstr_tok: ["Tests","XLA","and","CPU","kernels","generate","the","same","integers","in","overflow","case",".","Specifically","this","tests","the","case","where","the","counter","is","incremented","past","what","can","fit","within","64","bits","of","the","128","bit","Philox","counter","."]
code: def testXLAEqualsCPUAroundCounterOverflow(self):
      """Tests XLA and CPU kernels generate the same integers in overflow case.
  
      Specifically this tests the case where the counter is incremented past
      what can fit within 64 bits of the 128 bit Philox counter.
      """
      dtype = dtypes.uint64
      seed = 2**64 - 10
      shape = [315, 49]
      with ops.device("/device:CPU:0"):
          cpu_gen = random.Generator.from_seed(
              seed=seed, alg=random.RNG_ALG_PHILOX
          )
      with ops.device(xla_device_name()):
          xla_gen = random.Generator.from_seed(
              seed=seed, alg=random.RNG_ALG_PHILOX
          )
      # Repeat multiple times to make sure that the state after
      # number-generation are the same between CPU and XLA.
      for _ in range(5):
          with ops.device("/device:CPU:0"):
              # Test both number-generation and skip
              cpu = cpu_gen.uniform_full_int(shape=shape, dtype=dtype)
              cpu_gen.skip(100)
          with ops.device(xla_device_name()):
              xla = xla_gen.uniform_full_int(shape=shape, dtype=dtype)
              xla_gen.skip(100)
          self.assertAllEqual(cpu, xla)
          self.assertAllEqual(cpu_gen.state, xla_gen.state)
      self.assertAllEqual(cpu, xla)
  
imports: import itertools
  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 errors_impl
  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 gen_stateful_random_ops
  from tensorflow.python.ops import random_ops_util
  from tensorflow.python.ops import stateful_random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import flags
  from tensorflow.python.platform import test
label_desc: Use image node_id 7 for calling the StatefulRandomOpsTest obj's underlying member method code with example usage: obj.testXLAEqualsCPUAroundCounterOverflow() without return types