code: def get_latest_checkpoint(checkpoint_dir):
      import tensorflow as tf
  
      if is_local_path(checkpoint_dir):
          checkpoint_path = tf.train.latest_checkpoint(checkpoint_dir)
          return checkpoint_path
      else:
          try:
              temp_dir = tempfile.mkdtemp()
              # get checkpoint file
              remote_checkpoint_file = os.path.join(
                  checkpoint_dir, "checkpoint"
              )
              local_checkpoint_file = os.path.join(
                  temp_dir, "checkpoint"
              )
              get_remote_file_to_local(
                  remote_checkpoint_file, local_checkpoint_file
              )
              ckpt_name = None
              with open(local_checkpoint_file) as f:
                  import re
  
                  lines = f.readlines()
                  for line in lines:
                      m = re.compile(
                          '^model_checkpoint_path: "(.*)"$'
                      ).match(line)
                      if m:
                          ckpt_name = m.group(1)
                          break
              if ckpt_name:
                  return os.path.join(checkpoint_dir, ckpt_name)
              return None
          finally:
              shutil.rmtree(temp_dir)
  
imports: from contextlib import closing
  import socket
  import sys
  import tempfile
  import shutil
  from bigdl.dllib.utils import log4Error
  from bigdl.dllib.utils.common import callBigDlFunc
  from bigdl.dllib.utils.file_utils import get_file_list, is_local_path
  from bigdl.orca.data import SparkXShards
  from bigdl.orca.data.utils import get_size
  from bigdl.orca.data.file import put_local_dir_tree_to_remote, put_local_file_to_remote, get_remote_file_to_local, get_remote_dir_to_local
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from functools import partial
  import numpy
  from bigdl.orca.common import SafePickle
  import os
  import subprocess
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 36 for calling a global function with example usage: get_latest_checkpoint(checkpoint_dir) and returns: checkpoint_path, None, os