class_docstr: Test cases for unary operators.
class_docstr_tok: ["Test","cases","for","unary","operators","."]
code: def testCos(self):
      for dtype in self.float_types - {dtypes.bfloat16.as_numpy_dtype}:
          tol = 1e-6 if dtype == np.float32 else 1e-12
  
          x = np.linspace(-4 * np.e, 4 * np.e, num=1000, dtype=dtype)
          self._assertOpOutputMatchesExpected(
              math_ops.cos, x, expected=np.cos(x), rtol=tol, atol=tol
          )
  
          x = np.linspace(0.0, np.e * 1e-30, num=1000, dtype=dtype)
          self._assertOpOutputMatchesExpected(
              math_ops.cos, x, expected=np.cos(x), rtol=tol, atol=tol
          )
  
          if dtype == np.float64:
              x = np.linspace(0.0, np.e * 1e8, num=1000, dtype=dtype)
              self._assertOpOutputMatchesExpected(
                  math_ops.cos,
                  x,
                  expected=np.cos(x),
                  rtol=tol,
                  atol=1e-5,
              )
  
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 8 for calling the UnaryOpsTest obj's underlying member method code with example usage: obj.testCos() without return types