code: def optimize_onnx_model(origin_model, nchw_inputs=None):
      
      graph = origin_model.graph
      nodelist = list(graph.node)
      del graph.node[:]
  
      all_nodes = optimize_onnx(nodelist,
                                inputs=graph.input,
                                outputs=graph.output)
      nodes = [n_ for n_ in all_nodes if not isinstance(n_, tuple)]
      graph.node.extend(nodes)
  
      alter_tensors = {n_[1]: n_[0] for n_ in all_nodes if isinstance(n_, tuple)}
      update_tensor = lambda x: \
          helper.make_tensor(x.name, x.data_type, (x.dims[0], 1, 1),
                             onnx.numpy_helper.to_array(x).flatten())
      new_initializer = [init_ if init_.name not in alter_tensors else update_tensor(init_)
                         for init_ in graph.initializer]
      del graph.initializer[:]
      graph.initializer.extend(new_initializer)
  
      update_value_info = lambda x: \
          helper.make_tensor_value_info(x.name, x.type.tensor_type.elem_type,
                                        (x.type.tensor_type.shape.dim[0].dim_value, 1, 1))
      new_input = [in_ if in_.name not in alter_tensors else update_value_info(in_)
                   for in_ in graph.input]
      del graph.input[:]
      graph.input.extend(new_input)
      return origin_model
docs: the origin model will be updated after the optimization.
      :param origin_model:
      :param nchw_inputs:
      :return: