code: def _evaluate(
      model: Model, nodes_to_evaluate, x, y=None, auto_compile=False
  ):
      if not model._is_compiled:
          # tensorflow.python.keras.applications.*
          applications_model_names = [
              "densenet",
              "efficientnet",
              "inception_resnet_v2",
              "inception_v3",
              "mobilenet",
              "mobilenet_v2",
              "nasnet",
              "resnet",
              "resnet_v2",
              "vgg16",
              "vgg19",
              "xception",
          ]
          if model.name in applications_model_names:
              print(
                  'Transfer learning detected. Model will be compiled with ("categorical_crossentropy", "adam").'
              )
              print(
                  "If you want to change the default behaviour, then do in python:"
              )
              print('model.name = ""')
              print(
                  "Then compile your model with whatever loss you want: https://keras.io/models/model/#compile."
              )
              print(
                  "If you want to get rid of this message, add this line before calling keract:"
              )
              print(
                  'model.compile(loss="categorical_crossentropy", optimizer="adam")'
              )
              model.compile(
                  loss="categorical_crossentropy", optimizer="adam"
              )
          else:
              if auto_compile:
                  model.compile(loss="mse", optimizer="adam")
              else:
                  print(
                      "Please compile your model first! https://keras.io/models/model/#compile."
                  )
                  print(
                      "If you only care about the activations (outputs of the layers), "
                      "then just compile your model like that:"
                  )
                  print('model.compile(loss="mse", optimizer="adam")')
                  raise Exception("Compilation of the model required.")
  
      def eval_fn(k_inputs):
          try:
              return K.function(k_inputs, nodes_to_evaluate)(
                  model._standardize_user_data(x, y)
              )
          except (
              AttributeError
          ):  # one way to avoid forcing non eager mode.
              if y is None:  # tf 2.3.0 upgrade compatibility.
                  return K.function(k_inputs, nodes_to_evaluate)(x)
              return K.function(k_inputs, nodes_to_evaluate)(
                  (x, y)
              )  # although works.
          except ValueError as e:
              print(
                  "Run it without eager mode. Paste those commands at the beginning of your script:"
              )
              print("> import tensorflow as tf")
              print("> tf.compat.v1.disable_eager_execution()")
              raise e
  
      try:
          return eval_fn(
              model._feed_inputs
              + model._feed_targets
              + model._feed_sample_weights
          )
      except Exception:
          return eval_fn(model._feed_inputs)
  
imports: import json
  import os
  from collections import OrderedDict
  import numpy
  import tensorflow
  import tensorflow.keras.backend
  from tensorflow.keras import Sequential
  from tensorflow.keras.models import Model
label_desc: Use image node_id 4 for calling a global function with example usage: _evaluate(model, nodes_to_evaluate, x, y, auto_compile) and returns: eval_fn, K, eval_fn, K, K