code: def test_unary_ops(self):
      unary_operators = {
          torch.sin: torch._C._te.sin,
          torch.cos: torch._C._te.cos,
          torch.tan: torch._C._te.tan,
          torch.asin: torch._C._te.asin,
          torch.acos: torch._C._te.acos,
          torch.atan: torch._C._te.atan,
          torch.sinh: torch._C._te.sinh,
          torch.cosh: torch._C._te.cosh,
          torch.tanh: torch._C._te.tanh,
          torch.sigmoid: torch._C._te.sigmoid,
          torch.exp: torch._C._te.exp,
          torch.expm1: torch._C._te.expm1,
          torch.abs: torch._C._te.abs,
          torch.log: torch._C._te.log,
          torch.log2: torch._C._te.log2,
          torch.log10: torch._C._te.log10,
          torch.log1p: torch._C._te.log1p,
          torch.erf: torch._C._te.erf,
          torch.erfc: torch._C._te.erfc,
          torch.sqrt: torch._C._te.sqrt,
          torch.rsqrt: torch._C._te.rsqrt,
          torch.ceil: torch._C._te.ceil,
          torch.floor: torch._C._te.floor,
          torch.round: torch._C._te.round,
          torch.trunc: torch._C._te.trunc,
          torch.lgamma: torch._C._te.lgamma,
          torch.frac: torch._C._te.frac,
      }
  
      def construct_te_fn(op, n: int, dtype=torch.float32):
          A = torch._C._te.BufHandle("A", [n], dtype)
  
          def compute(i):
              return op(A.load([i]))
  
          C = te.Compute("C", [n], compute)
  
          loopnest = te.LoopNest([C])
          loopnest.prepare_for_codegen()
          stmt = te.simplify(loopnest.root_stmt())
  
          return te.construct_codegen("ir_eval", stmt, [A, C])
  
      n = 10
      a = torch.rand(n)
      for torch_op, te_op in unary_operators.items():
          ref = torch_op(a)
  
          te_fn = construct_te_fn(te_op, n, torch.float32)
          res = torch.empty(n)
          te_fn.call([a, res])
          assert torch.allclose(ref, res, atol=1e-3, rtol=1e-3)
  
imports: import torch
  import numpy
  import torch._C._te
  from torch.testing._internal.common_utils import run_tests
  from torch.testing._internal.jit_utils import JitTestCase
  import unittest
label_desc: Use image node_id 1 for calling the TestExprHandlePyBind obj's underlying member method code with example usage: obj.test_unary_ops() and returns: te, op