code: def test_custom_getter(self):
      # Custom getter that maintains call count and forwards to true getter
      custom_getter_count = [0]
  
      def custom_getter(getter, name, *args, **kwargs):
          custom_getter_count[0] += 1
          return getter(name, *args, **kwargs)
  
      # Test that custom getter is called both when variables are created and
      # subsequently accessed
      tmpl1 = template.make_template(
          "s1", variable_scoped_function, custom_getter_=custom_getter
      )
      self.assertEqual(custom_getter_count[0], 0)
      tmpl1()
      self.assertEqual(custom_getter_count[0], 1)
      tmpl1()
      self.assertEqual(custom_getter_count[0], 2)
  
      # Test that custom getter is called when the variable scope is created
      # during construction
      custom_getter_count[0] = 0
      tmpl2 = template.make_template(
          "s2",
          variable_scoped_function,
          custom_getter_=custom_getter,
          create_scope_now_=True,
      )
      self.assertEqual(custom_getter_count[0], 0)
      tmpl2()
      self.assertEqual(custom_getter_count[0], 1)
      tmpl2()
      self.assertEqual(custom_getter_count[0], 2)
  
imports: import functools
  import traceback
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import template
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  import tensorflow.python.ops.nn_grad
  from tensorflow.python.platform import test
  from tensorflow.python.training import gradient_descent
label_desc: Use image node_id 23 for calling the TemplateTest obj's underlying member method code with example usage: obj.test_custom_getter() and returns: getter