code: def regenerate_api_level_yaml():
      """
      regenerate api_level.yaml if there is no this file before.
      This is only called when api_level.yaml is missing.
      We re-constructed the revision history by its incremental id.
      We supposed that the duplicated function id is the fork point
      of API level. But once this file is created and committed,
      this function should never be called so that api_levels.yaml
      trace the revision history of nnabla APIs.
      """
      d = utils.load_yaml_ordered(
          open(join(here, "functions.yaml"), "r")
      )
  
      class APIInstance:
          pass
  
      api_instance_list = []
      for cat_name, cat_info in d.items():
          for func_name, func_info in d[cat_name].items():
              fids = func_info["function_ids"]
              for param, id in fids.items():
                  api_inst = APIInstance()
                  api_inst.func = func_name
                  api_inst.param = param
                  api_inst.id = id
                  api_instance_list.append(api_inst)
  
      api_instance_list = sorted(
          api_instance_list, key=lambda api: api.id
      )
  
      level = 1
      api_level = {}
      for api in api_instance_list:
          if level not in api_level:
              api_level[level] = {}
              api_level[level][api.func] = (api.param, api.id)
          elif api.func not in api_level[level]:
              api_level[level][api.func] = (api.param, api.id)
          else:
              level += 1
              api_level[level] = {}
              api_level[level][api.func] = (api.param, api.id)
  
      yaml_api_level = {}
      for level, funcs in api_level.items():
          if level not in yaml_api_level:
              yaml_api_level[level] = {}
          for func_name, (param, id) in funcs.items():
              yaml_api_level[level][func_name + "_" + param] = id
  
      utils.dump_yaml(
          yaml_api_level,
          open(join(here, "api_levels.yaml"), "w"),
          default_flow_style=False,
          width=80,
      )
  
file_path: nnabla/build-tools/code_generator/generate.py
imports: import sys
  from collections import OrderedDict
  from os.path import abspath, dirname, join, exists
  from contextlib import contextmanager
  import code_generator_utils
label_desc: Use image node_id 7 for calling a global function with example usage: regenerate_api_level_yaml() without return types