code: def _shrink_nnp(nnp, pos_start, pos_end):
      if (
          len(nnp.protobuf.executor) != 1
          or len(nnp.protobuf.network) != 1
      ):
          print("[ERROR] Please make only one network in nnp.")
          sys.exit(-1)
      from nnabla.utils import nnabla_pb2
  
      class _nnp:
          pass
  
      _nnp.protobuf = nnabla_pb2.NNablaProtoBuf()
      _nnp.other_files = nnp.other_files
      net = nnabla_pb2.NNablaProtoBuf().network.add()
      net.CopyFrom(nnp.protobuf.network[0])
  
      # Shrink network
      variables = {}
      net.ClearField("function")
      for i in range(pos_start, pos_end + 1):
          f = nnp.protobuf.network[0].function[i]
          func = net.function.add()
          func.CopyFrom(f)
          for v in func.input:
              variables[v] = True
          for v in func.output:
              variables[v] = True
  
      net.ClearField("variable")
      for v in nnp.protobuf.network[0].variable:
          if v.name in variables:
              variables[v.name] = v.type
              var = net.variable.add()
              var.CopyFrom(v)
  
      # Shrink parameter
      params = []
      for param in nnp.protobuf.parameter:
          if param.variable_name in variables:
              p = nnabla_pb2.NNablaProtoBuf().parameter.add()
              p.CopyFrom(param)
              params.append(p)
      for p in params:
          param = _nnp.protobuf.parameter.add()
          param.CopyFrom(p)
  
      # Shrink executor
      exe = nnabla_pb2.NNablaProtoBuf().executor.add()
      exe.CopyFrom(nnp.protobuf.executor[0])
  
      exe.ClearField("data_variable")
      for vname in nnp.protobuf.network[0].function[pos_start].input:
          if variables[vname] == "Buffer":
              v = exe.data_variable.add()
              v.variable_name = vname
  
      exe.ClearField("generator_variable")
      for var in nnp.protobuf.executor[0].generator_variable:
          if var.variable_name in variables:
              v = exe.generator_variable.add()
              v.CopyFrom(var)
  
      exe.ClearField("output_variable")
      for vname in nnp.protobuf.network[0].function[pos_end].output:
          if variables[vname] == "Buffer":
              v = exe.output_variable.add()
              v.variable_name = vname
  
      exe.ClearField("parameter_variable")
      for var in nnp.protobuf.executor[0].parameter_variable:
          if var.variable_name in variables:
              v = exe.parameter_variable.add()
              v.CopyFrom(var)
  
      n = _nnp.protobuf.network.add()
      n.CopyFrom(net)
      e = _nnp.protobuf.executor.add()
      e.CopyFrom(exe)
      return _nnp
  
file_path: nnabla/python/src/nnabla/utils/converter/commands.py
imports: import collections
  import os
  import sys
  from .nnabla import NnpImporter, NnpExporter
  from .nnablart import NnbExporter, CsrcExporter
  from .utils import func_set_import_nnp, func_set_import_onnx_config, func_set_import_config, func_set_nnabla_support, func_set_onnx_support, func_set_nnabla_version_decorate
  from nnabla.logger import logger
label_desc: Use image node_id 2 for calling a global function with example usage: _shrink_nnp(nnp, pos_start, pos_end) and returns: _nnp