docstr: Test shape inference.
docstr_tok: ["Test","shape","inference","."]
code: def testShapeInferenceV2(self):
      """Test shape inference."""
      x = np.arange(6).reshape(3, 2, 1)
      _, idx = gen_array_ops.unique_v2(x, axis=[0])
      self.assertEqual(idx.shape.as_list(), [3])
      _, idx = gen_array_ops.unique_v2(x, axis=[1])
      self.assertEqual(idx.shape.as_list(), [2])
      _, idx = gen_array_ops.unique_v2(x, axis=[2])
      self.assertEqual(idx.shape.as_list(), [1])
      _, idx = gen_array_ops.unique_v2(x, axis=[-1])
      self.assertEqual(idx.shape.as_list(), [1])
      _, idx = gen_array_ops.unique_v2(x, axis=[-2])
      self.assertEqual(idx.shape.as_list(), [2])
      _, idx = gen_array_ops.unique_v2(x, axis=[-3])
      self.assertEqual(idx.shape.as_list(), [3])
      _, idx = gen_array_ops.unique_v2([0, 1, 2], axis=[])
      self.assertEqual(idx.shape.as_list(), [3])
  
      with self.assertRaisesRegexp(
          ValueError, "axis expects a 1D vector"
      ):
          gen_array_ops.unique_v2(x, axis=[[0]])
  
      with self.assertRaisesRegexp(ValueError, "x expects a 1D vector"):
          gen_array_ops.unique_v2(x, axis=[])
  
      with self.assertRaisesRegexp(
          ValueError, "axis does not support input tensors larger than"
      ):
          gen_array_ops.unique_v2(x, axis=[1, 2])
  
      with self.assertRaisesRegexp(
          ValueError, r"axis expects to be in the range \[-3, 3\)"
      ):
          gen_array_ops.unique_v2(x, axis=[3])
  
      with self.assertRaisesRegexp(
          ValueError, r"axis expects to be in the range \[-3, 3\)"
      ):
          gen_array_ops.unique_v2(x, axis=[-4])
  
      x_t = array_ops.placeholder(dtypes.int32, shape=None)
      _, idx = gen_array_ops.unique_v2(x_t, axis=[0])
      self.assertEqual(idx.shape.as_list(), [None])
  
      axis_t = array_ops.placeholder(dtypes.int32, shape=None)
      _, idx = gen_array_ops.unique_v2(x, axis=axis_t)
      self.assertEqual(idx.shape.as_list(), [None])
  
imports: import numpy
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_array_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 8 for calling the UniqueTest obj's underlying member method code with example usage: obj.testShapeInferenceV2() without return types