code: def test_tf_optimizer_metrics(self):
      features = np.random.randn(20, 10)
      labels = np.random.randint(0, 10, size=[20])
      with tf.Graph().as_default():
          dataset = TFDataset.from_ndarrays(
              (features, labels),
              batch_size=4,
              val_tensors=(features, labels),
          )
          feature_tensor, label_tensor = dataset.tensors
          features = tf.layers.dense(feature_tensor, 8)
          output = tf.layers.dense(features, 10)
          loss = tf.reduce_mean(
              tf.losses.sparse_softmax_cross_entropy(
                  logits=output, labels=label_tensor
              )
          )
          optimizer = TFOptimizer.from_loss(
              loss,
              {"dense/": Adam(1e-3), "dense_1/": SGD(0.0)},
              val_outputs=[output],
              val_labels=[label_tensor],
              val_method=Accuracy(),
              metrics={"loss": loss},
          )
          initial_weights = (
              optimizer.tf_model.training_helper_layer.get_weights()
          )
          optimizer.optimize(end_trigger=MaxEpoch(1))
          updated_weights = (
              optimizer.tf_model.training_helper_layer.get_weights()
          )
          for i in [
              0,
              1,
          ]:  # weights and bias combined with "dense/" should be updated
              assert not np.allclose(
                  initial_weights[i], updated_weights[i]
              )
          for i in [
              2,
              3,
          ]:  # weights and bias combined with "dense_1" should be unchanged
              assert np.allclose(initial_weights[i], updated_weights[i])
          optimizer.sess.close()
  
file_path: BigDL/python/orca/test/bigdl/orca/tfpark/test_tfpark_tfoptimizer.py
imports: import pytest
  from bigdl.dllib.optim.optimizer import Adam, SGD, MaxEpoch
  from bigdl.dllib.keras.metrics import Accuracy
  from bigdl.orca.test_zoo_utils import ZooTestCase
  import tensorflow
  import numpy
  import tempfile
  import os
  from bigdl.orca.tfpark import TFDataset, TFOptimizer
label_desc: Use image node_id 3 for calling the TestTFParkTFOptimizer obj's underlying member method code with example usage: obj.test_tf_optimizer_metrics() without return types