code: def insert_pyfunc(
      func, Tout, stateful, name, *args
  ):  # pylint: disable=invalid-name
      """Calls tf.py_func and inserts the `func` in the internal registry."""
      result = tf.compat.v1.py_func(
          func, inp=list(args), Tout=Tout, stateful=stateful, name=name
      )
      # A py_func can either return a tensor or a list. Since we care only about the
      # op, it doesn't matter which result we take.
      if isinstance(result, list):
          first_result = result[0] if result else None
      else:
          first_result = result
      if first_result is None:
          raise ValueError(
              "func must return a tensor or list of tensors"
          )
      token = first_result.op.node_def.attr["token"].s
      tf.compat.v1.add_to_collection(
          _PYFUNC_COLLECTION_KEY, _PyFuncDef(token, func)
      )
      return result
  
file_path: transform/tensorflow_transform/py_func/pyfunc_helper.py
imports: import dill
  import tensorflow
  from tfx_bsl.types import tfx_namedtuple
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.framework import ops
label_desc: Use image node_id 1 for calling a global function with example usage: insert_pyfunc(func, Tout, stateful, name) and returns: result