code: def open_api_level_yaml():
      class ApiLevelManager:
          def __init__(self, d):
              self.changed = False
              self.api_level_d = d
              self.current_level = (
                  sorted(self.api_level_d.keys()).pop() + 1
              )
  
          def append_new_id(self, uniq_name, id):
              if self.current_level not in self.api_level_d:
                  self.api_level_d[self.current_level] = {uniq_name: id}
              else:
                  self.api_level_d[self.current_level][uniq_name] = id
              self.changed = True
  
      api_level_yaml = join(here, "api_levels.yaml")
      if not exists(api_level_yaml):
          regenerate_api_level_yaml()
      d = utils.load_yaml_ordered(open(api_level_yaml, "r"))
      api_level_man = ApiLevelManager(d)
      yield api_level_man
      if api_level_man.changed:
          utils.dump_yaml(
              api_level_man.api_level_d,
              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 8 for calling a global function with example usage: open_api_level_yaml() without return types