code: def get_last_dir(path):
      """Get the last directory of a path."""
      if os.path.isfile(path):
          # e.g: "../checkpoints/task_name/epoch0_step300/predict.txt"
          # return "epoch0_step300"
          last_dir = path.split("/")[-2]
  
      elif os.path.isdir(path):
          if path[-1] == "/":
              # e.g: "../checkpoints/task_name/epoch0_step300/"
              last_dir = path.split("/")[-2]
          else:
              # e.g: "../checkpoints/task_name/epoch0_step300"
              last_dir = path.split("/")[-1]
      else:
          # path or file is not existed
          warnings.warn("%s is not a existed file or path" % path)
          last_dir = ""
  
      return last_dir
  
imports: import sys
  import datetime
  import os
  import yaml
  import random
  import shutil
  import six
  import warnings
  import glob
label_desc: Use image node_id 1 for calling a global function with example usage: get_last_dir(path) and returns: last_dir