code: def analyse_config(cur_dir: str):
      """
      Analyse the model config in specified directory.
      Return a json object to describe configuration.
      """
      all_model_configs = {}
      all_model_versions = {}
      parent_dir, sub_dirs, filenames = os.walk(cur_dir).send(
          None
      )  # models can only put directory in model repository,
      # so we should only search depth 1 directories.
      for model_dir_name in sub_dirs:
          model_dir, model_sub_dirs, filenames = os.walk(
              os.path.join(parent_dir, model_dir_name)
          ).send(None)
          model_name = os.path.basename(model_dir)
          config_filenames = []
          for filename in filenames:
              if ".pbtxt" in filename:
                  config_filenames.append(
                      filename
                  )  # filenames with extension .pbtxt are all config files
          if config_filenames:
              default_config_filename = config_filenames[0]
              if "config.pbtxt" in config_filenames:
                  default_config_filename = "config.pbtxt"
                  config_filenames.remove(default_config_filename)
                  config_filenames.insert(0, default_config_filename)
              else:
                  # if no config.pbtxt, we choose the first file in config_filenames list to create config.pbtxt
                  copy_config_file_to_default_config(
                      model_dir, default_config_filename
                  )
                  default_config_filename = "config.pbtxt"
                  config_filenames.insert(0, default_config_filename)
              json_config = json.loads(
                  pbtxt2json(
                      open(
                          os.path.join(
                              model_dir, default_config_filename
                          )
                      ).read()
                  )
              )
              json_config["config_filenames"] = config_filenames[
                  0
              ]  # add config_filenames to config data (frontend developer said he only wanted one filename,
              # and to request config_filenames by get_config_filenames_for_one_model later)
              all_model_configs[
                  model_name
              ] = json_config  # store original config file content in json format
              json_config[
                  "name"
              ] = model_name  # because name in config data may be different from model_name,
              # model_name is model directory name actually, we should conform name with model_name.
          else:
              continue
          for model_sub_dir in model_sub_dirs:
              if re.match(
                  r"\d+", model_sub_dir
              ):  # version directory consists of numbers
                  if model_name not in all_model_versions:
                      all_model_versions[model_name] = {}
                  if (
                      model_sub_dir
                      not in all_model_versions[model_name]
                  ):
                      all_model_versions[model_name][model_sub_dir] = []
                  for version_resource_file in os.listdir(
                      os.path.join(model_dir, model_sub_dir)
                  ):
                      all_model_versions[model_name][
                          model_sub_dir
                      ].append(version_resource_file)
          if (
              model_name not in all_model_versions
          ):  # if a model has config but no version directory,
              # to convenient users, we create one
              all_model_versions[model_name] = {}
              os.mkdir(os.path.join(model_dir, "1"))
              all_model_versions[model_name]["1"] = []
  
      if not all_model_configs:
          raise Exception(
              "The path you choose is not a valid model repository, please choose a valid path."
          )
      return all_model_configs, all_model_versions
  
imports: import copy
  import json
  import os
  import random
  import re
  import signal
  import string
  from collections import defaultdict
  from subprocess import Popen
  from subprocess import STDOUT
  import google.protobuf.json_format
  import google.protobuf.text_format
  import psutil
  import requests
  from .proto.model_config_pb2 import ModelConfig
  from visualdl.utils.dir import FASTDEPLOYSERVER_PATH
label_desc: Use image node_id 4 for calling a global function with example usage: analyse_config(cur_dir) and returns: all_model_configs,  all_model_versions