code: def freeze_affine_getter(getter, *args, **kwargs):
      # custom getter to freeze affine params inside bn
      name = args[0] if len(args) else kwargs.get("name")
      if name.endswith("/gamma") or name.endswith("/beta"):
          kwargs["trainable"] = False
          ret = getter(*args, **kwargs)
          tf.add_to_collection(tf.GraphKeys.MODEL_VARIABLES, ret)
      else:
          ret = getter(*args, **kwargs)
      return ret
  
imports: import numpy
  import tensorflow
  from contextlib import ExitStack, contextmanager
  from tensorpack import tfv1
  from tensorpack.models import BatchNorm, Conv2D, MaxPooling, layer_register
  from tensorpack.tfutils import argscope
  from tensorpack.tfutils.scope_utils import auto_reuse_variable_scope
  from tensorpack.tfutils.varreplace import custom_getter_scope, freeze_variables
  from config import config
label_desc: Use image node_id 2 for calling a global function with example usage: freeze_affine_getter(getter) and returns: ret