code: def _make_observing_layer_call(
      old_call_fn: Callable[..., Any],
      key_prefix: str,
      output_dict: Dict[str, Any],
  ):
      """Returns a a function that wraps <Layer>.__call__ and observes arguments.
  
      The returned function can be used to replace DenseFeatures.__call__ and
      LinearModelLayer.__call__ so we can observe the features dictionary and the
      cols_to_output_dict dictionary. Note that the wrapper function is
      "observer-only" - it wraps around the old_call_fn and observes its
      arguments.
  
      Args:
        old_call_fn: The old __call__ function.
        key_prefix: Prefix for the keys in output_dict.
        output_dict: Dictionary to write observed arguments to.
  
      Returns:
        A function that wraps old_call_fn and observes arguments, that can be used
        to replace DenseFeatures.__call__ and LinearModelLayer.__call__.
      """
  
      def observing_call(self, *args, **kwargs):
          """Wrapper around old_call_fn that observes arguments."""
  
          callargs = inspect.getcallargs(
              old_call_fn, self, *args, **kwargs
          )
          features = callargs["features"]
          cols_to_output_tensors = callargs.get(
              "cols_to_output_tensors"
          )
  
          local_cols_to_output_tensors = {}
          if cols_to_output_tensors is not None:
              local_cols_to_output_tensors = cols_to_output_tensors
          result = old_call_fn(
              self,
              features=features,
              cols_to_output_tensors=local_cols_to_output_tensors,
          )
          output_dict[key_prefix + "_features"] = dict(features)
          output_dict[key_prefix + "_cols_to_output_tensors"] = dict(
              local_cols_to_output_tensors
          )
          return result
  
      return observing_call
  
imports: import contextlib
  import inspect
  import os
  import pickle
  from typing import Any, Callable, Dict, Optional
  import six
  import tensorflow
  from tensorflow import estimator
  import tensorflow_model_analysis
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.utils import util
  from tensorflow.python.feature_column import feature_column_v2
  from tensorflow_estimator.python.estimator.canned import dnn
label_desc: Use image node_id 1 for calling a global function with example usage: _make_observing_layer_call(old_call_fn, key_prefix, output_dict) and returns: observing_call, result