code: def config_network_precision(network, config):
      """
      The idea here is that ...
      TODO: make sure the weights are the ones after quantize and dequantize.
      In the network, bn has been folded by trt OnnxParser
      """
      # build two auxiliary indices
      out2layer = {}
      in2layer = {}
      for layer_idx in range(network.num_layers):
          layer = network.get_layer(layer_idx)
          for i in range(layer.num_outputs):
              output = layer.get_output(i)
              out2layer[output.name] = layer
          for i in range(layer.num_inputs):
              _input = layer.get_input(i)
              if _input.name in in2layer:
                  in2layer[_input.name].append(layer)
              else:
                  in2layer[_input.name] = [layer]
  
      net_input = network.get_input(0)
      assert net_input.name in in2layer
  
      # traverse the network/graph and specify precision and dynamic range
      for layer_idx in range(network.num_layers):
          # assume the traverse order is topological
          layer = network.get_layer(layer_idx)
          if layer.name in config:
              if layer.name[0:4] == "Gemm":
                  _handle_gemm(
                      layer, config[layer.name], out2layer, in2layer
                  )
              else:
                  apply_precision_to_layer(layer, config[layer.name])
          else:
              (
                  precision,
                  dynamic_range,
              ) = propagate_from_low_bit_predecessor(layer, out2layer)
              if precision:
                  layer.precision = precision
                  layer.set_output_type(0, precision)
              if dynamic_range:
                  out_tensor = layer.get_output(0)
                  out_tensor.dynamic_range = dynamic_range
  
      print_layer_precisions(network)
  
imports: import time
  import logging
  import tensorrt
  import numpy
  import torch
  from .None import frontend_to_onnx
  from .None import trt_pycuda
  from .backend import BaseModelSpeedup
label_desc: Use image node_id 6 for calling a global function with example usage: config_network_precision(network, config) without return types