code: def train_with_dataloader(
      exe,
      train_prog,
      compiled_train_prog,
      train_dataloader,
      train_fetch_list,
      train_metrics,
      epochs=10,
      log_interval=0,
      valid_interval=0,
      save_dir="./",
      save_model_name="model",
      fix_random_seed=False,
      compiled_test_prog=None,
      test_dataloader=None,
      test_fetch_list=None,
      test_metrics=None,
      is_profiler=None,
      profiler_path=None,
  ):
      if not train_dataloader:
          logger.error("[TRAIN] get dataloader failed.")
      epoch_periods = []
      train_loss = 0
      for epoch in range(epochs):
          log_lr_and_step()
  
          train_iter = 0
          epoch_periods = []
  
          for data in train_dataloader():
              cur_time = time.time()
              train_outs = exe.run(
                  compiled_train_prog,
                  fetch_list=train_fetch_list,
                  feed=data,
              )
              period = time.time() - cur_time
              epoch_periods.append(period)
              if log_interval > 0 and (train_iter % log_interval == 0):
                  train_metrics.calculate_and_log_out(
                      train_outs,
                      info="[TRAIN] Epoch {}, iter {} ".format(
                          epoch, train_iter
                      ),
                  )
              train_iter += 1
  
              # NOTE: profiler tools, used for benchmark
              if (
                  is_profiler
                  and epoch == 0
                  and train_iter == log_interval
              ):
                  profiler.start_profiler("All")
              elif (
                  is_profiler
                  and epoch == 0
                  and train_iter == log_interval + 5
              ):
                  profiler.stop_profiler("total", profiler_path)
                  return
  
          if len(epoch_periods) < 1:
              logger.info(
                  "No iteration was executed, please check the data reader"
              )
              sys.exit(1)
  
          logger.info(
              "[TRAIN] Epoch {} training finished, average time: {}".format(
                  epoch, np.mean(epoch_periods[1:])
              )
          )
          save_model(
              exe,
              train_prog,
              save_dir,
              save_model_name,
              "_epoch{}".format(epoch),
              save_type=".pdckpt",
          )
          save_model(
              exe,
              train_prog,
              save_dir,
              save_model_name,
              "_epoch{}".format(epoch),
              save_type=".pdparams",
          )
          if (
              compiled_test_prog
              and valid_interval > 0
              and (epoch + 1) % valid_interval == 0
          ):
              test_with_dataloader(
                  exe,
                  compiled_test_prog,
                  test_dataloader,
                  test_fetch_list,
                  test_metrics,
                  log_interval,
                  save_model_name,
              )
  
      save_model(
          exe,
          train_prog,
          save_dir,
          save_model_name,
          "_final",
          save_type=".pdckpt",
      )
      save_model(
          exe,
          train_prog,
          save_dir,
          save_model_name,
          "_final",
          save_type=".pdparams",
      )
      # when fix_random seed for debug
      if fix_random_seed:
          cards = os.environ.get("CUDA_VISIBLE_DEVICES")
          gpu_num = len(cards.split(","))
          print(
              "kpis\ttrain_cost_card{}\t{}".format(gpu_num, train_loss)
          )
          print(
              "kpis\ttrain_speed_card{}\t{}".format(
                  gpu_num, np.mean(epoch_periods)
              )
          )
  
file_path: PaddleHub/modules/video/classification/videotag_tsn_lstm/resource/utils/train_utils.py
imports: import os
  import sys
  import logging
  import time
  import numpy
  import paddle.fluid
  from paddle.fluid import profiler
label_desc: Use image node_id 3 for calling a global function with example usage: train_with_dataloader(exe, train_prog, compiled_train_prog, train_dataloader, train_fetch_list, train_metrics, epochs, log_interval, valid_interval, save_dir, save_model_name, fix_random_seed, compiled_test_prog, test_dataloader, test_fetch_list, test_metrics, is_profiler, profiler_path) without return types