class_docstr: Test cases for unary operators.
class_docstr_tok: ["Test","cases","for","unary","operators","."]
code: def testAllTypeOps(self):
      for dtype in self.numeric_types - {np.int8, np.uint8}:
          self._assertOpOutputMatchesExpected(
              array_ops.diag,
              np.array([1, 2, 3, 4], dtype=dtype),
              np.array(
                  [
                      [1, 0, 0, 0],
                      [0, 2, 0, 0],
                      [0, 0, 3, 0],
                      [0, 0, 0, 4],
                  ],
                  dtype=dtype,
              ),
          )
          self._assertOpOutputMatchesExpected(
              array_ops.diag_part,
              np.arange(36).reshape([2, 3, 2, 3]).astype(dtype),
              np.array([[0, 7, 14], [21, 28, 35]], dtype=dtype),
          )
          self._assertOpOutputMatchesExpected(
              array_ops.diag,
              np.array([[1, 2], [3, 4]], dtype=dtype),
              np.array(
                  [
                      [[[1, 0], [0, 0]], [[0, 2], [0, 0]]],
                      [[[0, 0], [3, 0]], [[0, 0], [0, 4]]],
                  ],
                  dtype=dtype,
              ),
          )
  
          self._assertOpOutputMatchesExpected(
              array_ops.identity,
              np.array([[-1, 1]], dtype=dtype),
              expected=np.array([[-1, 1]], dtype=dtype),
          )
  
          self._assertOpOutputMatchesExpected(
              array_ops.prevent_gradient,
              np.array([[-1, 1]], dtype=dtype),
              expected=np.array([[-1, 1]], dtype=dtype),
          )
  
          self._assertOpOutputMatchesExpected(
              array_ops.squeeze,
              np.array([[[[[]]]]], dtype=dtype),
              expected=np.array([], dtype=dtype),
          )
          self._assertOpOutputMatchesExpected(
              array_ops.squeeze,
              np.array([[[1], [2]]], dtype=dtype),
              expected=np.array([1, 2], dtype=dtype),
          )
          self._assertOpOutputMatchesExpected(
              array_ops.squeeze,
              np.array([[[1]], [[2]]], dtype=dtype),
              expected=np.array([1, 2], dtype=dtype),
          )
          self._assertOpOutputMatchesExpected(
              array_ops.squeeze,
              np.array([[[1, 2], [3, 4]]], dtype=dtype),
              expected=np.array([[1, 2], [3, 4]], dtype=dtype),
          )
  
          self._assertOpOutputMatchesExpected(
              array_ops.stop_gradient,
              np.array([[-1, 1]], dtype=dtype),
              expected=np.array([[-1, 1]], dtype=dtype),
          )
  
imports: import platform
  import unittest
  import numpy
  import six
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import dtypes
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import bitwise_ops
  from tensorflow.python.ops import gen_functional_ops
  from tensorflow.python.ops import gen_nn_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 5 for calling the UnaryOpsTest obj's underlying member method code with example usage: obj.testAllTypeOps() without return types