code: def load_dnd(model_dir):
      latest_checkpoint_id = -1
      latest_checkpoint = ""
      # get all checkpoint files
      for fname in os.listdir(model_dir):
          path = os.path.join(model_dir, fname)
          if os.path.isdir(path) or fname.split(".")[-1] != "srs":
              continue
          checkpoint_id = int(fname.split("_")[0])
          if checkpoint_id > latest_checkpoint_id:
              latest_checkpoint = fname
              latest_checkpoint_id = checkpoint_id
  
      with open(
          os.path.join(model_dir, str(latest_checkpoint)), "rb"
      ) as f:
          DND = pickle.load(f)
  
          for a in range(DND.num_actions):
              DND.dicts[a].index = AnnoyIndex(512, metric="euclidean")
              DND.dicts[a].index.set_seed(1)
  
              for idx, key in zip(
                  range(DND.dicts[a].curr_size),
                  DND.dicts[a].embeddings[: DND.dicts[a].curr_size],
              ):
                  DND.dicts[a].index.add_item(idx, key)
  
              DND.dicts[a].index.build(50)
  
      return DND
  
imports: import os
  import pickle
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: load_dnd(model_dir) and returns: DND