code: def get_last_checkpoint(folder):
      content = os.listdir(folder)
      checkpoints = [
          path
          for path in content
          if _re_checkpoint.search(path) is not None
          and os.path.isdir(os.path.join(folder, path))
      ]
      if len(checkpoints) == 0:
          return
      return os.path.join(
          folder,
          max(
              checkpoints,
              key=lambda x: int(_re_checkpoint.search(x).groups()[0]),
          ),
      )
  
imports: import copy
  import functools
  import gc
  import inspect
  import os
  import random
  import re
  import threading
  import time
  from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union
  import numpy
  from .utils import ExplicitEnum, is_psutil_available, is_tf_available, is_torch_available, is_torch_cuda_available, is_torch_tpu_available, requires_backends
label_desc: Use image node_id 4 for calling a global function with example usage: get_last_checkpoint(folder) and returns: os