code: def get_config():
      logger.auto_set_dir()
  
      data3, wd2id = get_PennTreeBank()
      global VOCAB_SIZE
      VOCAB_SIZE = len(wd2id)
      steps_per_epoch = (data3[0].shape[0] // BATCH - 1) // SEQ_LEN
  
      train_data = TensorInput(
          lambda: ptb_producer(data3[0], BATCH, SEQ_LEN),
          steps_per_epoch,
      )
      val_data = TensorInput(
          lambda: ptb_producer(data3[1], BATCH, SEQ_LEN),
          (data3[1].shape[0] // BATCH - 1) // SEQ_LEN,
      )
  
      test_data = TensorInput(
          lambda: ptb_producer(data3[2], BATCH, SEQ_LEN),
          (data3[2].shape[0] // BATCH - 1) // SEQ_LEN,
      )
  
      M = Model()
      return TrainConfig(
          data=train_data,
          model=M,
          callbacks=[
              ModelSaver(),
              HyperParamSetterWithFunc(
                  "learning_rate", lambda e, x: x * 0.80 if e > 6 else x
              ),
              RunOp(lambda: M.reset_lstm_state()),
              InferenceRunner(val_data, [ScalarStats(["cost"])]),
              RunOp(lambda: M.reset_lstm_state()),
              InferenceRunner(
                  test_data,
                  [ScalarStats(["cost"], prefix="test")],
                  tower_name="InferenceTowerTest",
              ),
              RunOp(lambda: M.reset_lstm_state()),
              CallbackFactory(
                  trigger=lambda self: [
                      self.trainer.monitors.put_scalar(
                          "validation_perplexity",
                          np.exp(
                              self.trainer.monitors.get_latest(
                                  "validation_cost"
                              )
                              / SEQ_LEN
                          ),
                      ),
                      self.trainer.monitors.put_scalar(
                          "test_perplexity",
                          np.exp(
                              self.trainer.monitors.get_latest(
                                  "test_cost"
                              )
                              / SEQ_LEN
                          ),
                      ),
                  ]
              ),
          ],
          max_epoch=70,
      )
  
file_path: tensorpack/examples/PennTreebank/PTB-LSTM.py
imports: import argparse
  import numpy
  import os
  import tensorflow
  from tensorpack import *
  from tensorpack.tfutils import gradproc, optimizer, summary
  from tensorpack.utils import logger
  from tensorpack.utils.argtools import memoized_ignoreargs
  from tensorpack.utils.fs import download, get_dataset_path
  import reader
  from reader import ptb_producer
label_desc: Use image node_id 2 for calling a global function with example usage: get_config() and returns: TrainConfig