# Path: utils/import_finder.py
# def find_files_to_copy(toCheck, base_path="./"):
#     """
#     Given a filename, returns a list of all source files in the current directory being
#     used.
#     """
#     importedItems = [toCheck]
# 
#     if base_path == "":
#         base_path = "./"
# 
#     src_files = crawl_directories(base_path)
#     modulify = [to_module(p) for p in src_files]
# 
#     with open(toCheck, "r") as pyFile:
#         for line in pyFile:
#             # ignore comments
#             line = line.strip().partition("#")[0].partition(" as ")[0].split(" ")
# 
#             if line[0] == "import" or line[0] == "from":
#                 if line[1] in modulify:
#                     importedItems.append(to_path(line[1]))
#                     importedItems += find_files_to_copy(to_path(line[1]))
# 
#     return sorted(list(set(importedItems)))


import os
import shutil
import configargparse
import numpy as np
    import tensorflow as tf
        import tensorflow as tf
from dataclasses import dataclass
from distutils.dir_util import copy_tree
from typing import List, Optional, Union
from utils.import_finder import find_files_to_copy
            name_to_step = lambda name: int(
                name.replace(self.to_watch[0].name + "_", "").replace(".npy", ""),
            )
            ckpts = sorted(
                [
                    f
                    for f in os.listdir(
                        os.path.join(self.args.basedir, self.args.expname)
                    )
                    if self.to_watch[0].name in f
                ],
                key=name_to_step,
            )
            print("Found ckpts", ckpts)
            if len(ckpts) > 0:
                step = name_to_step(ckpts[-1])
            else:
                return 0

        for sri in self.to_watch:
            print("Restoring", sri.obj, sri.name, step)
            if sri.is_variable:
                StateRestoration.restore_variable(self.args, sri.obj, sri.name, step)
            else:
                StateRestoration.restore_weights(self.args, sri.obj, sri.name, step)

        return step

    @classmethod
    def build_save_path(cls, args, prefix, i):

# Path: utils/import_finder.py
# def find_files_to_copy(toCheck, base_path="./"):
#     """
#     Given a filename, returns a list of all source files in the current directory being
#     used.
#     """
#     importedItems = [toCheck]
# 
#     if base_path == "":
#         base_path = "./"
# 
#     src_files = crawl_directories(base_path)
#     modulify = [to_module(p) for p in src_files]
# 
#     with open(toCheck, "r") as pyFile:
#         for line in pyFile:
#             # ignore comments
#             line = line.strip().partition("#")[0].partition(" as ")[0].split(" ")
# 
#             if line[0] == "import" or line[0] == "from":
#                 if line[1] in modulify:
#                     importedItems.append(to_path(line[1]))
#                     importedItems += find_files_to_copy(to_path(line[1]))
# 
#     return sorted(list(set(importedItems)))


# Path: utils/training_setup_utils.py
import os
import shutil
import configargparse
import numpy as np
    import tensorflow as tf
        import tensorflow as tf
from dataclasses import dataclass
from distutils.dir_util import copy_tree
from typing import List, Optional, Union
from utils.import_finder import find_files_to_copy

            name_to_step = lambda name: int(
                name.replace(self.to_watch[0].name + "_", "").replace(".npy", ""),
            )
            ckpts = sorted(
                [
                    f
                    for f in os.listdir(
                        os.path.join(self.args.basedir, self.args.expname)
                    )
                    if self.to_watch[0].name in f
                ],
                key=name_to_step,
            )
            print("Found ckpts", ckpts)
            if len(ckpts) > 0:
                step = name_to_step(ckpts[-1])
            else:
                return 0

        for sri in self.to_watch:
            print("Restoring", sri.obj, sri.name, step)
            if sri.is_variable:
                StateRestoration.restore_variable(self.args, sri.obj, sri.name, step)
            else:
                StateRestoration.restore_weights(self.args, sri.obj, sri.name, step)

        return step

    @classmethod
    def build_save_path(cls, args, prefix, i):

        return os.path.join(