code: def _save_to_dir(
      folder,
      sess,
      graph,
      metric_tensors,
      batch_size_tensor,
      loss_tensor,
      inputs,
      labels,
      predictions,
      trainable_variables,
      trainable_variable_placeholders,
      trainable_assign,
      extra_variables,
      extra_variable_assign_placeholders,
      extra_variable_assign,
      grads,
      update_op,
      train_op,
      additional_inputs,
      additional_values,
  ):
      import tensorflow as tf
      from tensorflow import gfile
  
      saver = tf.train.Saver()
      if not os.path.isdir(folder):
          os.makedirs(folder)
      saver.save(
          sess, os.path.join(folder, "model"), write_meta_graph=False
      )
  
      meta = {
          "inputs": [i.name for i in inputs],
          "input_types": [i.dtype.as_datatype_enum for i in inputs],
          "additional_inputs": [i.name for i in additional_inputs],
          "additional_input_types": [
              i.dtype.as_datatype_enum for i in additional_inputs
          ],
          "labels": [l.name for l in labels],
          "label_types": [i.dtype.as_datatype_enum for i in labels],
          "predictions": [t.name for t in predictions]
          if predictions
          else [],
          "metric_tensors": [t.name for t in metric_tensors],
          "batch_size_tensor": batch_size_tensor.name,
          "loss_tensor": loss_tensor.name,
          "variables": [v.name for v in trainable_variables],
          "variable_types": [
              v.dtype.as_datatype_enum
              for v in trainable_variable_placeholders
          ],
          "variable_assign_placeholders": [
              v.name for v in trainable_variable_placeholders
          ],
          "assign_variable_op": trainable_assign.name,
          "extra_variables": [v.name for v in extra_variables],
          "extra_variable_types": [
              v.dtype.as_datatype_enum
              for v in extra_variable_assign_placeholders
          ],
          "extra_variable_assign_placeholders": [
              p.name for p in extra_variable_assign_placeholders
          ],
          "assign_extra_variable_op": extra_variable_assign.name,
          "grad_variables": [g.name for g in grads],
          "update_op": update_op.name,
          "restore_op": saver.saver_def.restore_op_name,
          "restore_path_placeholder": saver.saver_def.filename_tensor_name,
          "save_op": _to_operation_name(
              saver.saver_def.save_tensor_name
          ),
          "save_path_placeholder": saver.saver_def.filename_tensor_name,
          "default_tensor_value": [
              _to_floats(v) for v in additional_values
          ],
          "init_op": tf.tables_initializer().name,
      }
  
      if train_op is not None:
          meta["train_op"] = train_op.name
  
      with open(os.path.join(folder, "training_meta.json"), "w") as f:
          f.write(json.dumps(meta))
  
      with gfile.GFile(os.path.join(folder, "model.meta"), "wb") as f:
          f.write(graph.as_graph_def().SerializeToString())
  
      return meta, saver
  
imports: import json
  import logging
  import os
  import sys
  import tempfile
  from bigdl.dllib.nn.criterion import Criterion
  from bigdl.dllib.nn.layer import Layer
  from bigdl.dllib.optim.optimizer import MaxEpoch, EveryEpoch
  from bigdl.dllib.utils.common import to_list, JavaValue
  from bigdl.dllib.utils.file_utils import callZooFunc
  from bigdl.dllib.feature.common import FeatureSet
  from bigdl.dllib.keras.engine.topology import to_bigdl_metric, Loss, OptimMethod
  from bigdl.dllib.net.utils import find_placeholders, to_bigdl_optim_method, find_tensors
  from bigdl.dllib.estimator.estimator import Estimator
  from bigdl.dllib.utils import nest
  from bigdl.dllib.utils.triggers import EveryEpoch
  from bigdl.dllib.utils.triggers import ZooTrigger
  from bigdl.orca.tfpark.tf_dataset import TFNdarrayDataset, check_data_compatible
  from bigdl.orca.tfpark.tf_dataset import _standarize_feature_label_dataset
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 7 for calling the TFModel obj's underlying member method code with example usage: obj._save_to_dir(folder, sess, graph, metric_tensors, batch_size_tensor, loss_tensor, inputs, labels, predictions, trainable_variables, trainable_variable_placeholders, trainable_assign, extra_variables, extra_variable_assign_placeholders, extra_variable_assign, grads, update_op, train_op, additional_inputs, additional_values) and returns: meta,  saver