code: def _create_monitor(ctx, monitor):
      datasets = ctx.datasets
      if monitor["network"] not in ctx.networks:
          raise ValueError(
              "{} is not found in networks.".format(monitor["network"])
          )
      proto_network = ctx.proto_graphs[
          monitor["network"]
      ].default_graph()
      m = nnabla_pb2.Monitor()
      m.name = monitor["name"]
      m.network_name = monitor["network"]
      if isinstance(monitor["dataset"], (list, tuple)):
          for dataset_name in monitor["dataset"]:
              if dataset_name in datasets:
                  m.dataset_name.append(dataset_name)
                  dataset = datasets[dataset_name]
              else:
                  raise ValueError(
                      "Invalid dataset name is found in monitor definition: {}".format(
                          dataset_name
                      )
                  )
      elif isinstance(monitor["dataset"], str):
          dataset_name = monitor["dataset"]
          if dataset_name in datasets:
              m.dataset_name.append(dataset_name)
              dataset = datasets[dataset_name]
      if dataset is None:
          raise ValueError(
              "Dataset is not defined in monitor definition."
          )
      for var_name, data_name in monitor.get(
          "data_variables", {}
      ).items():
          d = m.data_variable.add()
          d.variable_name = var_name
          d.data_name = data_name
      for out in monitor.get(
          "monitor_variables", proto_network.outputs
      ):
          d = m.monitor_variable.add()
          d.type = "Error"
          d.variable_name = out
      for g_var in monitor.get("generator_variables", []):
          d = m.generator_variable.add()
          d.variable_name = g_var
          d.type = "Constant"
          d.multiplier = 0
      return m
  
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 7 for calling a global function with example usage: _create_monitor(ctx, monitor) and returns: m