class_docstr: History of changes:
  python 2.x to python 3.x.
  merge utils.py into eval to save one file.
  reference: https://github.com/LisaAnne/LocalizingMoments/blob/master/utils/eval.py
  Code to evaluate your results on the DiDeMo dataset.
class_docstr_tok: ["History","of","changes",":","python","2.x","to","python","3.x",".","merge","utils.py","into","eval","to","save","one","file",".","reference",":","https",":","\/\/github.com\/LisaAnne\/LocalizingMoments\/blob\/master\/utils\/eval.py","Code","to","evaluate","your","results","on","the","DiDeMo","dataset","."]
docstr: Inputs:
  segments: For each item in the ground truth data, rank possible video segments given the description and video.
      In DiDeMo, there are 21 posible moments extracted for each video so the list of video segments will be of length 21.
      The first video segment should be the video segment that best corresponds to the text query.
      There are 4180 sentence in the validation data, so when evaluating a model on the val dataset,
      segments should be a list of lenght 4180, and each item in segments should be a list of length 21.
  data: ground truth data
docstr_tok: ["Inputs",":","segments",":","For","each","item","in","the","ground","truth","data",",","rank","possible","video","segments","given","the","description","and","video",".","In","DiDeMo",",","there","are","21","posible","moments","extracted","for","each","video","so","the","list","of","video","segments","will","be","of","length","21",".","The","first","video","segment","should","be","the","video","segment","that","best","corresponds","to","the","text","query",".","There","are","4180","sentence","in","the","validation","data",",","so","when","evaluating","a","model","on","the","val","dataset",",","segments","should","be","a","list","of","lenght","4180",",","and","each","item","in","segments","should","be","a","list","of","length","21.","data",":","ground","truth","data"]
code: def _eval_predictions(self, segments, data):
      """
      Inputs:
      segments: For each item in the ground truth data, rank possible video segments given the description and video.
          In DiDeMo, there are 21 posible moments extracted for each video so the list of video segments will be of length 21.
          The first video segment should be the video segment that best corresponds to the text query.
          There are 4180 sentence in the validation data, so when evaluating a model on the val dataset,
          segments should be a list of lenght 4180, and each item in segments should be a list of length 21.
      data: ground truth data
      """
      average_ranks = []
      average_iou = []
      for s, d in zip(segments, data):
          pred = s[0]
          ious = [self._iou(pred, t) for t in d["times"]]
          average_iou.append(np.mean(np.sort(ious)[-3:]))
          ranks = [
              self._rank(s, t) for t in d["times"] if tuple(t) in s
          ]  # if t in s] is added for s, e not in prediction.
          average_ranks.append(np.mean(np.sort(ranks)[:3]))
      rank1 = np.sum(np.array(average_ranks) <= 1) / float(
          len(average_ranks)
      )
      rank5 = np.sum(np.array(average_ranks) <= 5) / float(
          len(average_ranks)
      )
      miou = np.mean(average_iou)
  
      # print("Average rank@1: %f" % rank1)
      # print("Average rank@5: %f" % rank5)
      # print("Average iou: %f" % miou)
      return rank1, rank5, miou
  
imports: import numpy
  import json
label_desc: Use image node_id 6 for calling the DiDeMoMetric obj's underlying member method code with example usage: obj._eval_predictions(segments, data) and returns: rank1,  rank5,  miou