class_docstr: Test cases for unary operators.
class_docstr_tok: ["Test","cases","for","unary","operators","."]
code: def testIntOps(self):
      for dtype in self.int_types:
          self._assertOpOutputMatchesExpected(
              bitwise_ops.invert,
              np.array([0, -1, 1, 16, 42], dtype=dtype),
              expected=np.array([-1, 0, -2, -17, -43], dtype=dtype),
          )
  
          # Test population_count for array inputs.
          raw_inputs = [
              0,
              1,
              -1,
              3,
              -3,
              5,
              -5,
              14,
              -14,
              127,
              128,
              255,
              256,
              65535,
              65536,
              2**31 - 1,
              2**31,
              2**32 - 1,
              2**32,
              -(2**32) + 1,
              -(2**32),
              -(2**63) + 1,
              2**63 - 1,
          ]
          # Only choose inputs which fit in the int dtype.
          raw_inputs = list(
              filter(
                  lambda x: np.iinfo(dtype).min
                  <= x
                  <= np.iinfo(dtype).max,
                  raw_inputs,
              )
          )
          inputs = np.array(raw_inputs, dtype=dtype)
  
          def count_bits(x):
              return sum(
                  bin(z).count("1") for z in six.iterbytes(x.tobytes())
              )
  
          truth = [count_bits(x) for x in inputs]
          self._assertOpOutputMatchesExpected(
              bitwise_ops.population_count,
              inputs,
              expected=np.array(truth, dtype=np.uint8),
              equality_test=self.AssertAllEqual,
          )
  
          # Test population_count for scalar inputs.
          for raw_inp in raw_inputs:
              inp = dtype(raw_inp)
              truth = count_bits(inp)
              self._assertOpOutputMatchesExpected(
                  bitwise_ops.population_count,
                  inp,
                  expected=np.uint8(truth),
                  equality_test=self.AssertAllEqual,
              )
  
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 13 for calling the UnaryOpsTest obj's underlying member method code with example usage: obj.testIntOps() and returns: sum