class_docstr: Compares the results of a slice assignment using Tensorflow and numpy.
class_docstr_tok: ["Compares","the","results","of","a","slice","assignment","using","Tensorflow","and","numpy","."]
code: def __setitem__(self, index, value):
      self.which_mode = 1 - self.which_mode
      value = np.array(value).astype(self.dtype)
  
      with self.test.session() as sess, self.test.test_scope():
          x = constant_op.constant(self.x_np, dtype=self.dtype)
          var = resource_variable_ops.ResourceVariable(x)
          sess.run(variables.variables_initializer([var]))
  
          if self.which_mode == 0:
              val = sess.run(var[index].assign(value))
          else:
              assert self.which_mode == 1
              val = sess.run(state_ops.assign(var[index], value))
          valnp = np.copy(self.x_np)
          valnp[index] = np.array(value)
          self.test.assertAllEqual(val, valnp)
  
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 2 for calling the StridedSliceAssignChecker obj's underlying member method code with example usage: obj.__setitem__(index, value) without return types