code: def finalize_and_log_out(
      self, info="", label_file="./label_3396.txt"
  ):
      if self.mode == "infer":
          all_res_list = []
          for index, item in enumerate(self.infer_results):
              video_id = item[0]
              f = io.open(label_file, "r", encoding="utf-8")
              fl = f.readlines()
              res = {}
              res["path"] = video_id
              res["prediction"] = {}
              for i in range(len(item[1])):
                  class_id = item[1][i]
                  class_prob = item[2][i]
                  if class_prob < self.threshold:
                      continue
                  class_name = fl[class_id].split("\n")[0]
                  res["prediction"][class_name] = class_prob
              if not res["prediction"]:
                  logger.warning(
                      "%s: No prediction exceeds the threshold = %s."
                      % (video_id, self.threshold)
                  )
              all_res_list.append(res)
          return all_res_list
      else:
          epoch_info_dict = self.calculator.get()
          logger.info(
              info
              + "\tavg_hit_at_one: {0},\tavg_perr: {1},\tavg_loss :{2},\taps: {3},\tgap:{4}".format(
                  epoch_info_dict["avg_hit_at_one"],
                  epoch_info_dict["avg_perr"],
                  epoch_info_dict["avg_loss"],
                  epoch_info_dict["aps"],
                  epoch_info_dict["gap"],
              )
          )
  
imports: from __future__ import absolute_import
  from __future__ import unicode_literals
  from __future__ import print_function
  from __future__ import division
  import io
  import logging
  import numpy
  from videotag_tsn_lstm.resource.metrics.youtube8m import eval_util
label_desc: Use image node_id 4 for calling the Youtube8mMetrics obj's underlying member method code with example usage: obj.finalize_and_log_out(info, label_file) and returns: all_res_list