code: def save(
      filename,
      contents,
      include_params=False,
      variable_batch_size=True,
      extension=".nnp",
      parameters=None,
      parameter_format=".h5",
      include_solver_state=False,
      solver_state_format=".h5",
  ):
      """Save network definition, inference/training execution
      configurations etc.
  
      Args:
          filename (str or file object): Filename to store information. The file
              extension is used to determine the saving file format.
              ``.nnp``: (Recommended) Creating a zip archive with nntxt (network
              definition etc.) and h5 (parameters).
              ``.nntxt``: Protobuf in text format.
              ``.protobuf``: Protobuf in binary format (unsafe in terms of
               backward compatibility).
          contents (dict): Information to store.
          include_params (bool): Includes parameter into single file. This is
              ignored when the extension of filename is nnp.
          variable_batch_size (bool):
              By ``True``, the first dimension of all variables is considered
              as batch size, and left as a placeholder
              (more specifically ``-1``). The placeholder dimension will be
              filled during/after loading.
          extension: if files is file-like object, extension is one of ".nntxt", ".prototxt", ".protobuf", ".h5", ".nnp".
          parameter_format: ".h5" or ".protobuf". Allow to choose which parameter file type.
          include_solver_state (bool): Indicate whether to save solver state or not.
          solver_state_format (str):
              '.h5' or '.protobuf', default '.h5', indicate in which format will solver state be saved,
              notice that this option only works when save network definition in .nnp format
              and include_solver_state is True.
  
      Example:
          The following example creates a two inputs and two
          outputs MLP, and save the network structure and the initialized
          parameters.
  
          .. code-block:: python
  
              import nnabla as nn
              import nnabla.functions as F
              import nnabla.parametric_functions as PF
              from nnabla.utils.save import save
  
              batch_size = 16
              x0 = nn.Variable([batch_size, 100])
              x1 = nn.Variable([batch_size, 100])
              h1_0 = PF.affine(x0, 100, name='affine1_0')
              h1_1 = PF.affine(x1, 100, name='affine1_0')
              h1 = F.tanh(h1_0 + h1_1)
              h2 = F.tanh(PF.affine(h1, 50, name='affine2'))
              y0 = PF.affine(h2, 10, name='affiney_0')
              y1 = PF.affine(h2, 10, name='affiney_1')
  
              contents = {
                  'networks': [
                      {'name': 'net1',
                       'batch_size': batch_size,
                       'outputs': {'y0': y0, 'y1': y1},
                       'names': {'x0': x0, 'x1': x1}}],
                  'executors': [
                      {'name': 'runtime',
                       'network': 'net1',
                       'data': ['x0', 'x1'],
                       'output': ['y0', 'y1']}]}
              save('net.nnp', contents)
  
  
          To get a trainable model, use following code instead.
  
          .. code-block:: python
  
              contents = {
              'global_config': {'default_context': ctx},
              'training_config':
                  {'max_epoch': args.max_epoch,
                   'iter_per_epoch': args_added.iter_per_epoch,
                   'save_best': True},
              'networks': [
                  {'name': 'training',
                   'batch_size': args.batch_size,
                   'outputs': {'loss': loss_t},
                   'names': {'x': x, 'y': t, 'loss': loss_t}},
                  {'name': 'validation',
                   'batch_size': args.batch_size,
                   'outputs': {'loss': loss_v},
                   'names': {'x': x, 'y': t, 'loss': loss_v}}],
              'optimizers': [
                  {'name': 'optimizer',
                   'solver': solver,
                   'network': 'training',
                   'dataset': 'mnist_training',
                   'weight_decay': 0,
                   'lr_decay': 1,
                   'lr_decay_interval': 1,
                   'update_interval': 1}],
              'datasets': [
                  {'name': 'mnist_training',
                   'uri': 'MNIST_TRAINING',
                   'cache_dir': args.cache_dir + '/mnist_training.cache/',
                   'variables': {'x': x, 'y': t},
                   'shuffle': True,
                   'batch_size': args.batch_size,
                   'no_image_normalization': True},
                  {'name': 'mnist_validation',
                   'uri': 'MNIST_VALIDATION',
                   'cache_dir': args.cache_dir + '/mnist_test.cache/',
                   'variables': {'x': x, 'y': t},
                   'shuffle': False,
                   'batch_size': args.batch_size,
                   'no_image_normalization': True
                   }],
              'monitors': [
                  {'name': 'training_loss',
                   'network': 'validation',
                   'dataset': 'mnist_training'},
                  {'name': 'validation_loss',
                   'network': 'validation',
                   'dataset': 'mnist_validation'}],
              }
  
  
      """
      ctx = FileHandlerContext()
      ext = extension
      if isinstance(filename, str):
          _, ext_c = os.path.splitext(filename)
          ext = ext_c if ext_c else ext
      include_params = False if ext == ".nnp" else include_params
      save_solver_in_proto = include_solver_state and ext != ".nnp"
      ctx.proto = create_proto(
          contents,
          include_params,
          variable_batch_size,
          save_solver_in_proto,
      )
      ctx.parameters = parameters
      if include_solver_state and ext == ".nnp":
          if "optimizers" not in contents:
              raise KeyError(
                  "optimizers should be specified in \
                  contents when include_solver_state is True"
              )
          _format_opti_config_for_states_checkpoint(ctx, contents)
          file_savers = get_default_file_savers(
              parameter_format=parameter_format,
              solver_state_format=solver_state_format,
          )
      else:
          file_savers = get_default_file_savers(
              parameter_format=parameter_format
          )
      save_files(ctx, file_savers, filename, ext)
      logger.info(
          "Model file is saved as ({}): {}".format(ext, filename)
      )
  
file_path: nnabla/python/src/nnabla/utils/save.py
imports: import os
  import re
  import types
  import nnabla
  import numpy
  from collections import OrderedDict
  from nnabla.logger import logger
  from nnabla.parameter import get_parameters
  from nnabla.utils import nnabla_pb2
  from nnabla.utils.get_file_handle import FileHandlerContext, get_default_file_savers, save_files
label_desc: Use image node_id 10 for calling a global function with example usage: save(filename, contents, include_params, variable_batch_size, extension, parameters, parameter_format, include_solver_state, solver_state_format) without return types