code: def test_smart_ag(self):
      def foo(x):
          if x > 0:
              y = x * x
          else:
              y = -x
          return y
  
      with self.assertRaises(Exception):
          # Without autograph `foo` should not be traceable.
          func_foo = tf.function(foo, autograph=False)
          func_foo(tf.constant(2.0))
  
      smart_foo = utils.smart_autograph(foo)
      func_smart_foo = tf.function(smart_foo, autograph=False)
      for x in tf.range(-10, 10):
          y = foo(x)
          self.assertAllEqual(smart_foo(x), y)
          self.assertAllEqual(func_smart_foo(x), y)
  
imports: from absl.testing import parameterized
  import numpy
  from sonnet.src import initializers
  from sonnet.src import test_utils
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 1 for calling the SmartAutographTest obj's underlying member method code with example usage: obj.test_smart_ag() and returns: y