code: def _network(proto, default_context, batch_size, all_variables, rng):
      network = Network()
      network.name = proto.name
      # Read Repeat Info
      network.repeat_info = {}
      for r in proto.repeat_info:
          network.repeat_info[r.id] = r.times
  
      network.variables = OrderedDict()
  
      if batch_size is None:
          network.batch_size = proto.batch_size
      else:
          network.batch_size = batch_size
  
      for v in proto.variable:
          for variable_index in itertools.product(
              *map(
                  tuple,
                  map(
                      range,
                      [network.repeat_info[id] for id in v.repeat_id],
                  ),
              )
          ):
              name = v.name
              for index, i in enumerate(variable_index):
                  if "{" + v.repeat_id[index] + "}" in name:
                      name = name.replace(
                          "{" + v.repeat_id[index] + "}",
                          "[" + str(i) + "]",
                      )
                  else:
                      name += (
                          "_" + v.repeat_id[index] + "[" + str(i) + "]"
                      )
              if name in all_variables:
                  variable = all_variables[name]
              else:
                  shape = tuple(
                      [
                          d if d >= 1 else network.batch_size
                          for d in v.shape.dim
                      ]
                  )
                  variable = _create_variable(v, name, shape, rng)
                  all_variables[name] = variable
              network.variables[name] = variable
              logger.debug(
                  "{}".format(
                      (
                          name,
                          variable.shape,
                          v.initializer.type
                          if v.initializer.type
                          else "-",
                          v.initializer.multiplier,
                      )
                  )
              )
  
      network.functions = OrderedDict()
      network.function_inputs = OrderedDict()
      network.function_outputs = OrderedDict()
      network.variable_inputs = OrderedDict()
      network.variable_outputs = OrderedDict()
      for f in proto.function:
          ctx = (
              default_context
              if not f.context.backends
              else _context(f.context)
          )
  
          for variable_index in itertools.product(
              *map(
                  tuple,
                  map(
                      range,
                      [network.repeat_info[id] for id in f.repeat_id],
                  ),
              )
          ):
              (
                  function,
                  input_variable_names,
                  output_variable_names,
              ) = _create_function(ctx, network, f, variable_index)
              if function is not None:
                  network.functions[function.name] = function
                  for v_name in output_variable_names:
                      network.variable_inputs[
                          network.variables[v_name]
                      ] = [function]
                  for v_name in input_variable_names:
                      if (
                          not network.variables[v_name]
                          in network.variable_outputs
                      ):
                          network.variable_outputs[
                              network.variables[v_name]
                          ] = []
                      network.variable_outputs[
                          network.variables[v_name]
                      ].append(function)
  
      network.setup(optimize=True)
      return network
  
imports: from collections import OrderedDict
  import google.protobuf.text_format
  import itertools
  import numpy
  import os
  import re
  import shutil
  import tempfile
  from nnabla.initializer import NormalInitializer, UniformInitializer, ConstantInitializer, RangeInitializer, calc_normal_std_he_forward, calc_normal_std_he_backward, calc_normal_std_glorot, calc_uniform_lim_glorot
  from nnabla.logger import logger
  from nnabla.parameter import get_parameter_or_create
  from nnabla.utils import nnabla_pb2
  from nnabla.utils.data_iterator import data_iterator_csv_dataset, data_iterator_cache
  from nnabla.utils.create_cache import CreateCache
  from nnabla.utils.load_function import _create_function_instance
  from nnabla.utils.nnp_format import nnp_version
  from nnabla.utils.communicator_util import current_communicator, single_or_rankzero
  from nnabla.utils.learning_rate_scheduler import PolynomialScheduler, CosineScheduler, ExponentialScheduler, StepScheduler, LinearWarmupScheduler
  from legacy_network import Network
  from nnabla.utils.progress import progress
  from legacy_get_file_handle import get_file_handle_load, get_buf_type
  import nnabla
  import nnabla.function
  import nnabla.solver
label_desc: Use image node_id 5 for calling a global function with example usage: _network(proto, default_context, batch_size, all_variables, rng) and returns: network