class_docstr: Test cases for stateful random-number generator operators.
class_docstr_tok: ["Test","cases","for","stateful","random-number","generator","operators","."]
docstr: Tests that proper errors are raised.
      
docstr_tok: ["Tests","that","proper","errors","are","raised","."]
code: def testErrors(self):
      """Tests that proper errors are raised."""
      shape = [2, 3]
      with ops.device(xla_device_name()):
          gen = random.Generator.from_seed(
              seed=1234, alg=random.RNG_ALG_THREEFRY
          )
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              r"algorithm.* must be of shape \[\], not",
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  gen.state.handle, [0, 0], shape
              )
          with self.assertRaisesWithPredicateMatch(
              TypeError, "EagerTensor of dtype int64"
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  gen.state.handle, 1.1, shape
              )
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              "Unsupported algorithm id",
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  gen.state.handle, 123, shape
              )
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              "Unsupported algorithm id",
          ):
              gen_stateful_random_ops.rng_read_and_skip(
                  gen.state.handle, alg=123, delta=10
              )
          var = variables.Variable([0, 0], dtype=dtypes.uint32)
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              "Trying to read variable .* Expected int64 got",
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  var.handle, random.RNG_ALG_THREEFRY, shape
              )
          var = variables.Variable([[0]], dtype=dtypes.int64)
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              "RNG state must have one and only one dimension, not",
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  var.handle, random.RNG_ALG_THREEFRY, shape
              )
          var = variables.Variable([0], dtype=dtypes.int64)
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              "The size of the state must be at least",
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  var.handle, random.RNG_ALG_THREEFRY, shape
              )
          var = variables.Variable([0, 0], dtype=dtypes.int64)
          with self.assertRaisesWithPredicateMatch(
              errors_impl.InvalidArgumentError,
              "The size of the state must be at least",
          ):
              gen_stateful_random_ops.stateful_standard_normal_v2(
                  var.handle, random.RNG_ALG_PHILOX, shape
              )
  
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 17 for calling the StatefulRandomOpsTest obj's underlying member method code with example usage: obj.testErrors() without return types