class_docstr: Test cases for resource variable operators.
class_docstr_tok: ["Test","cases","for","resource","variable","operators","."]
code: def testInvalidShape(self):
      pattern = re.compile("shapes must be equal", re.IGNORECASE)
      # test invalid shape on assign_add in XLA
      with self.assertRaisesRegex(Exception, pattern):
          with self.session() as sess, self.test_scope():
              v = resource_variable_ops.ResourceVariable([0, 1, 2, 3])
              sess.run(variables.variables_initializer([v]))
              x = v.assign_add(1)
              sess.run(x)
  
      # test invalid shape raised on assign_sub in XLA
      with self.assertRaisesRegex(Exception, pattern):
          with self.session() as sess, self.test_scope():
              v = resource_variable_ops.ResourceVariable([0, 1, 2, 3])
              sess.run(variables.variables_initializer([v]))
              x = v.assign_sub(1)
              sess.run(x)
  
imports: import re
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_state_ops
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import googletest
  from tensorflow.python.training.gradient_descent import GradientDescentOptimizer
label_desc: Use image node_id 8 for calling the VariableOpsTest obj's underlying member method code with example usage: obj.testInvalidShape() without return types