code: def save_optimizer_states(filebase, ext, train_config):
      filelist = []
      if ext == ".protobuf":
          filename = filebase + "_optimizer.protobuf.optimizer"
          proto = nnabla_pb2.NNablaProtoBuf()
          proto_optimizers = []
          for o in train_config.optimizers.values():
              proto_optimizers.append(
                  _create_optimizer_lite(o.optimizer)
              )
          proto.optimizer.extend(proto_optimizers)
          with get_file_handle_save(filename, ".protobuf") as f:
              f.write(proto.SerializeToString())
              filelist.append(filename)
      else:
          for o in train_config.optimizers.values():
              f_name = "{}_{}_optimizer.h5".format(
                  o.optimizer.name,
                  re.sub(r"(|Cuda)$", "", str(o.optimizer.solver.name)),
              )
              filename = "{}_{}".format(filebase, f_name)
              o.optimizer.solver.save_states(filename)
              name_ext = "{}.optimizer".format(filename)
              os.rename(filename, name_ext)
              filelist.append(name_ext)
      return filelist
  
imports: import os
  import re
  import timeit
  from contextlib import contextmanager
  import nnabla
  import nnabla.utils.callback
  import numpy
  from nnabla.config import nnabla_config
  from nnabla.logger import logger
  from nnabla.utils import nnabla_pb2
  from nnabla.utils.communicator_util import current_communicator
  from nnabla.utils.get_file_handle import get_file_handle_save, get_decorated_file_loader, load_files
  from contextlib import contextmanager
  import nnabla.logger
  from nnabla.lms import SwapInOutScheduler
label_desc: Use image node_id 9 for calling a global function with example usage: save_optimizer_states(filebase, ext, train_config) and returns: filelist