code: def dump_function_object(self, func, prototxt, net):
      assert isinstance(func, _function_types)
      layer_name = self._get_layer_name(func)
      parent_layer_names = [
          self._get_parent_name(input_.creator)
          for input_ in func.inputs
      ]
      params = collections.OrderedDict()
      params["type"] = None
      params["name"] = layer_name
      params["bottom"] = parent_layer_names
      params["top"] = [layer_name]
      layer = None
      if net is not None:
          layer = net.layer.add()
      if func.label == "LinearFunction":
          if len(func.inputs) == 2:
              _, W = func.inputs
              b = None
          else:
              _, W, b = func.inputs
          n_out, n_in = W.shape
          inner_product_param = {
              "num_output": n_out,
              "bias_term": b is not None,
          }
          params["type"] = "InnerProduct"
          params["inner_product_param"] = inner_product_param
          params["bottom"] = params["bottom"][:1]
  
          if net is not None:
              for k, v in six.iteritems(inner_product_param):
                  setattr(layer.inner_product_param, k, v)
              _add_blob(layer, list(W.shape), W.data)
              if b is not None:
                  b.retain_data()
                  _add_blob(layer, list(b.shape), b.data)
  
      elif func.label in (
          "Convolution2DFunction",
          "Deconvolution2DFunction",
      ):
          if len(func.inputs) == 2:
              _, W = func.inputs
              b = None
          else:
              _, W, b = func.inputs
          n_out, n_in, kw, kh = W.shape
          convolution_param = {
              "num_output": n_out,
              "bias_term": b is not None,
              "pad_w": func.pw,
              "pad_h": func.ph,
              "stride_w": func.sx,
              "stride_h": func.sy,
              "kernel_w": kw,
              "kernel_h": kh,
              "group": func.groups,
          }
  
          params["bottom"] = params["bottom"][:1]
          if func.label == "Convolution2DFunction":
              params["type"] = "Convolution"
          else:
              params["type"] = "Deconvolution"
              convolution_param["num_output"] = n_in
          params["convolution_param"] = convolution_param
  
          if net is not None:
              for k, v in six.iteritems(convolution_param):
                  setattr(layer.convolution_param, k, v)
  
              _add_blob(layer, [n_out, n_in, kh, kw], W.data)
  
              if b is not None:
                  b.retain_data()
                  _add_blob(layer, [n_out], b.data)
  
      elif func.label == "AveragePooling2D":
          kw = func.kw
          kh = func.kh
          pooling_param = {
              "pool": 1,
              "pad_w": func.pw,
              "pad_h": func.ph,
              "stride_w": func.sx,
              "stride_h": func.sy,
              "kernel_w": kw,
              "kernel_h": kh,
          }
          params["type"] = "Pooling"
          params["pooling_param"] = pooling_param
          if net is not None:
              for k, v in six.iteritems(pooling_param):
                  setattr(layer.pooling_param, k, v)
  
      elif func.label == "MaxPoolingND" and func.ndim == 2:
          kh, kw = func.ksize
          sy, sx = func.stride
          ph, pw = func.pad
          pooling_param = {
              "pool": 0,
              "pad_w": pw,
              "pad_h": ph,
              "stride_w": sx,
              "stride_h": sy,
              "kernel_w": kw,
              "kernel_h": kh,
          }
          params["type"] = "Pooling"
          params["pooling_param"] = pooling_param
          if net is not None:
              for k, v in six.iteritems(pooling_param):
                  setattr(layer.pooling_param, k, v)
  
      elif func.label == "LocalResponseNormalization":
          lrn_param = {
              "norm_region": 0,  # ACROSS_CHANNELS
              "local_size": func.n,
              "k": func.k,
              "alpha": func.alpha * func.n,
              "beta": func.beta,
          }
          params["type"] = "LRN"
          params["lrn_param"] = lrn_param
          if net is not None:
              for k, v in six.iteritems(lrn_param):
                  setattr(layer.lrn_param, k, v)
  
      elif func.label == "FixedBatchNormalization":
          _, gamma, beta, mean, var = func.inputs
          batch_norm_param = {"use_global_stats": True, "eps": func.eps}
          params["type"] = "BatchNorm"
          params["bottom"] = params["bottom"][:1]
          params["batch_norm_param"] = batch_norm_param
          if net is not None:
              for k, v in six.iteritems(batch_norm_param):
                  setattr(layer.batch_norm_param, k, v)
              _add_blob(layer, [mean.data.size], mean.data)
              _add_blob(layer, [var.data.size], var.data)
              _add_blob(
                  layer, [1], numpy.ones((1,), dtype=numpy.float32)
              )
  
          if gamma.data is None and beta.data is None:
              pass
          else:
              bn_name = layer_name + "_bn"
              params["name"] = bn_name
              params["top"] = [bn_name]
              if prototxt is not None:
                  prototxt.write(self._gen_layer_prototxt(params))
              if net is not None:
                  layer.name = params["name"]
                  layer.type = params["type"]
                  layer.bottom[:] = params["bottom"]
                  layer.top[:] = params["top"]
                  layer.phase = caffe_pb.TEST
              del params, layer
              params = collections.OrderedDict()
              params["type"] = "Scale"
              params["name"] = layer_name
              params["bottom"] = [bn_name]
              params["top"] = [layer_name]
              if net is not None:
                  layer = net.layer.add()
              beta.retain_data()
              bias_term = beta.data is not None
              scale_param = {
                  "axis": 1,
                  "bias_term": bias_term,
              }
              params["scale_param"] = scale_param
              if net is not None:
                  for k, v in six.iteritems(scale_param):
                      setattr(layer.scale_param, k, v)
                  _add_blob(layer, [gamma.data.size], gamma.data)
                  if bias_term:
                      _add_blob(layer, [beta.data.size], beta.data)
  
      elif func.label == "ReLU":
          params["type"] = "ReLU"
  
      elif func.label == "LeakyReLU":
          relu_param = {"negative_slope": func.slope}
          params["type"] = "ReLU"
          params["relu_param"] = relu_param
          if net is not None:
              for k, v in six.iteritems(relu_param):
                  setattr(layer.relu_param, k, v)
  
      elif func.label == "Concat":
          axis = func.axis
          concat_param = {"axis": axis}
          params["type"] = "Concat"
          params["concat_param"] = concat_param
          if net is not None:
              for k, v in six.iteritems(concat_param):
                  setattr(layer.concat_param, k, v)
  
      elif func.label == "Softmax":
          params["type"] = "Softmax"
  
      elif func.label == "Sigmoid":
          params["type"] = "Sigmoid"
  
      elif func.label == "Reshape":
          input_ = func.inputs[0]
          parent = input_.creator
          parent_layer_name = parent_layer_names[0]
          if "Reshape" in parent_layer_name:
              grandparent = parent.inputs[0].creator
              parent_layer_name = self._get_parent_name(grandparent)
          reshape_param = {"shape": {"dim": list(func.shape)}}
          params["type"] = "Reshape"
          params["bottom"] = [parent_layer_name]
          params["reshape_param"] = reshape_param
          if layer is not None:
              dim = reshape_param["shape"]["dim"]
              layer.reshape_param.shape.dim[:] = dim
  
      elif func.label == "_ + _":
          params["type"] = "Eltwise"
  
      else:
          raise Exception(
              "Cannot convert, name={}, rank={}, label={}, inputs={}".format(
                  layer_name, func.rank, func.label, parent_layer_names
              )
          )
      if prototxt is not None:
          prototxt.write(self._gen_layer_prototxt(params))
  
      if net is not None:
          layer.name = params["name"]
          layer.type = params["type"]
          layer.bottom[:] = params["bottom"]
          layer.top[:] = params["top"]
          layer.phase = caffe_pb.TEST
  
imports: import collections
  import heapq
  import os
  import numpy
  import six
  import chainer
  from chainer import function
  from chainer import function_node
  from chainer.links.caffe.protobuf3 import caffe_pb2
  from chainer import variable
label_desc: Use image node_id 5 for calling the _RetrieveAsCaffeModel obj's underlying member method code with example usage: obj.dump_function_object(func, prototxt, net) without return types