code: def convert_to_tflayer_args(args_names, name_mapping):
      """
      After applying this decorator:
      1. data_format becomes tf.layers style
      2. nl becomes activation
      3. initializers are renamed
      4. positional args are transformed to corresponding kwargs, according to args_names
      5. kwargs are mapped to tf.layers names if needed, by name_mapping
      """
  
      def decorator(func):
          @functools.wraps(func)
          def decorated_func(inputs, *args, **kwargs):
              kwargs = map_common_tfargs(kwargs)
  
              posarg_dic = {}
              assert len(args) <= len(args_names), (
                  "Please use kwargs instead of positional args to call this model, "
                  "except for the following arguments: {}".format(
                      ", ".join(args_names)
                  )
              )
              for pos_arg, name in zip(args, args_names):
                  posarg_dic[name] = pos_arg
  
              ret = {}
              for name, arg in six.iteritems(kwargs):
                  newname = name_mapping.get(name, None)
                  if newname is not None:
                      assert (
                          newname not in kwargs
                      ), "Argument {} and {} conflicts!".format(
                          name, newname
                      )
                  else:
                      newname = name
                  ret[newname] = arg
              ret.update(
                  posarg_dic
              )  # Let pos arg overwrite kw arg, for argscope to work
  
              return func(inputs, **ret)
  
          return decorated_func
  
      return decorator
  
file_path: tensorpack/tensorpack/models/tflayer.py
imports: import functools
  import six
  import tensorflow
  from ..tfutils.common import get_tf_version_tuple
  from ..tfutils.varreplace import custom_getter_scope
  from ..utils.argtools import get_data_format
label_desc: Use image node_id 2 for calling a global function with example usage: convert_to_tflayer_args(args_names, name_mapping) and returns: decorator, decorated_func, func