code: def train_model_init(self, model, features, mode, params):
      source = self.get_train_from_input(features, params)
      _, loss, metric_name, metric = model(source)
      global_step = tf.train.get_or_create_global_step()
      optimizer = tf_euler.utils.optimizers.get(
          params.get("optimizer", "adam")
      )(params.get("learning_rate", 0.001))
      train_op = optimizer.minimize(loss, global_step)
      hooks = []
      tensor_to_log = {
          "step": global_step,
          "loss": loss,
          metric_name: metric,
      }
      hooks.append(
          tf.train.LoggingTensorHook(
              tensor_to_log, every_n_iter=params.get("log_steps", 100)
          )
      )
      spec = tf.estimator.EstimatorSpec(
          mode=mode, loss=loss, train_op=train_op, training_hooks=hooks
      )
      return spec
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import json
  import numpy
  import tensorflow
  import tf_euler
label_desc: Use image node_id 9 for calling the BaseEstimator obj's underlying member method code with example usage: obj.train_model_init(model, features, mode, params) and returns: spec