code: def has_finished(save_dir):
      train_log = os.path.join(save_dir, "train.log")
      if not os.path.exists(train_log):
          return False
      with open(train_log) as h:
          lines = h.readlines()
          if len(lines) == 0:
              return False
          if "Finished run" in lines[-1]:
              return True
      return False
  
file_path: mmf/tools/sweeps/lib/slurm.py
imports: import datetime
  import itertools
  import os
  import random
  import shlex
  import shutil
  import subprocess
  from collections import OrderedDict
  from glob import glob
  from mmf.utils.general import get_mmf_root
label_desc: Use image node_id 4 for calling a global function with example usage: has_finished(save_dir) and returns: False, False, False, True