code: def run_worker(task_spec, checkpoints_path, batch_size=32, epochs=10):
      device_fn = (
          task_spec.device_fn() if task_spec is not None else None
      )
      # create graph
      with tf.Graph().as_default():
          global_step = tf.train.get_or_create_global_step()
          with tf.device(device_fn):
              # load dataset
              (
                  images_input,
                  one_hot_classes,
                  num_classes,
                  dataset_size,
              ) = load_data(
                  file=TRAIN_FILE,
                  task_spec=task_spec,
                  batch_size=batch_size,
                  epochs=epochs,
                  shuffle_size=10000,
              )
              # network
              network, predictions = build_network(
                  images_input,
                  num_classes=num_classes,
                  is_training=True,
              )
              # training operations
              loss = tl.cost.sigmoid_cross_entropy(
                  output=network.outputs,
                  target=one_hot_classes,
                  name="loss",
              )
              steps_per_epoch = dataset_size / batch_size
              learning_rate = tf.train.exponential_decay(
                  learning_rate=0.045,
                  global_step=global_step,
                  decay_steps=steps_per_epoch * 2,  # 2 epochs
                  decay_rate=0.94,
                  staircase=True,
                  name="learning_rate",
              )
              optimizer = tf.train.RMSPropOptimizer(
                  learning_rate=learning_rate, decay=0.9, epsilon=1.0
              )
              # clip and apply gradients
              gvs = optimizer.compute_gradients(
                  loss=loss, var_list=network.all_params
              )
              capped_gvs = []
              for grad, var in gvs:
                  if grad is not None:
                      grad = tf.clip_by_value(grad, -2.0, 2.0)
                  capped_gvs.append((grad, var))
              train_op = optimizer.apply_gradients(
                  grads_and_vars=capped_gvs, global_step=global_step
              )
              # metrics
              tf.summary.scalar("learning_rate/value", learning_rate)
              tf.summary.scalar("loss/logits", loss)
              _, metrics_average_ops, metrics_ops = calculate_metrics(
                  predicted_batch=predictions,
                  real_batch=one_hot_classes,
                  is_training=True,
              )
              with tf.control_dependencies([train_op]):
                  train_op = tf.group(metrics_average_ops)
  
          # start training
          hooks = [StopAtStepHook(last_step=steps_per_epoch * epochs)]
          with tl.distributed.DistributedSession(
              task_spec=task_spec,
              hooks=hooks,
              checkpoint_dir=checkpoints_path,
              save_summaries_secs=None,
              save_summaries_steps=300,
              save_checkpoint_secs=60 * 60,
          ) as sess:
              # print network information
              if task_spec is None or task_spec.is_master():
                  network.print_params(False, session=sess)
                  network.print_layers()
                  sys.stdout.flush()
              # run training
              try:
                  last_log_time = time.time()
                  next_log_time = last_log_time + 60
                  while not sess.should_stop():
                      (
                          step,
                          loss_val,
                          learning_rate_val,
                          _,
                          metrics,
                      ) = sess.run(
                          [
                              global_step,
                              loss,
                              learning_rate,
                              train_op,
                              metrics_ops,
                          ]
                      )
                      if task_spec is None or task_spec.is_master():
                          now = time.time()
                          if now > next_log_time:
                              last_log_time = now
                              next_log_time = last_log_time + 60
                              current_epoch = "{:.3f}".format(
                                  float(step) / steps_per_epoch
                              )
                              max_steps = epochs * steps_per_epoch
                              m = "Epoch: {}/{} Steps: {}/{} Loss: {} Learning rate: {} Metrics: {}"
                              logging.info(
                                  m.format(
                                      current_epoch,
                                      epochs,
                                      step,
                                      max_steps,
                                      loss_val,
                                      learning_rate_val,
                                      metrics,
                                  )
                              )
              except OutOfRangeError:
                  pass
  
imports: import argparse
  import logging
  import multiprocessing
  import os
  import random
  import sys
  import time
  from xml.etree import ElementTree
  import numpy
  import tensorflow
  from tensorflow.contrib import slim
  from tensorflow.contrib.slim.python.slim.nets.inception_v3 import inception_v3, inception_v3_arg_scope
  from tensorflow.python.framework.errors_impl import OutOfRangeError
  from tensorflow.python.training import session_run_hook
  from tensorflow.python.training.basic_session_run_hooks import StopAtStepHook
  from tensorflow.python.training.monitored_session import SingularMonitoredSession
  import tensorlayer
label_desc: Use image node_id 9 for calling a global function with example usage: run_worker(task_spec, checkpoints_path, batch_size, epochs) without return types