class_docstr: The ModelGraph represents the network that is being processed by hls4ml.
  
  Args:
      config (dict):  The configuration dictionary
      layer_list (list(dict)):  The list contains a dictionary for each input layer
      inputs (list, optional):  The inputs to the model. If None, determined from layer_list
      outputs (list, optional):  The outputs to the model. If None, determined from layer_list
docstr: Insert a new node into the model graph.
  
  The node to be inserted should be created with `make_node()` function. The optional
  parameter `before` can be used to specify the node that follows in case of ambiguities.
  
  Args:
      node (Layer): Node to insert
      before (Layer, optional): The next node in sequence before which a
          new node should be inserted.
      input_idx (int, optional): If the next node takes multiple inputs, the input index
  Raises:
      Exception: If an attempt to insert a node with multiple inputs is made or if
          `before` does not specify a correct node in sequence.
docstr_tok: ["Insert","a","new","node","into","the","model","graph",".","The","node","to","be","inserted","should","be","created","with","`","make_node","(",")","`","function",".","The","optional","parameter","`","before","`","can","be","used","to","specify","the","node","that","follows","in","case","of","ambiguities",".","Args",":","node","(","Layer",")",":","Node","to","insert","before","(","Layer",",","optional",")",":","The","next","node","in","sequence","before","which","a","new","node","should","be","inserted",".","input_idx","(","int",",","optional",")",":","If","the","next","node","takes","multiple","inputs",",","the","input","index","Raises",":","Exception",":","If","an","attempt","to","insert","a","node","with","multiple","inputs","is","made","or","if","`","before","`","does","not","specify","a","correct","node","in","sequence","."]
code: def insert_node(self, node, before=None, input_idx=0):
      """Insert a new node into the model graph.
  
      The node to be inserted should be created with `make_node()` function. The optional
      parameter `before` can be used to specify the node that follows in case of ambiguities.
  
      Args:
          node (Layer): Node to insert
          before (Layer, optional): The next node in sequence before which a
              new node should be inserted.
          input_idx (int, optional): If the next node takes multiple inputs, the input index
      Raises:
          Exception: If an attempt to insert a node with multiple inputs is made or if
              `before` does not specify a correct node in sequence.
  
      """
      if len(node.inputs) > 1:
          raise Exception(
              "Cannot insert a node with more than one input (for now)."
          )
  
      prev_node = node.get_input_node(node.inputs[0])
      next_nodes = []
      for x in self.graph.values():
          overlap = [
              value for value in x.inputs if value in prev_node.outputs
          ]
          if overlap:
              next_nodes.append(x)
  
      if before is None:
          next_node = next(
              (
                  x
                  for x in self.graph.values()
                  if x.inputs[0] in prev_node.outputs
              ),
              None,
          )
      else:
          if before not in next_nodes:
              raise Exception(
                  "Cannot insert a node {} before {} (candidates: {}).".format(
                      node.name,
                      before.name,
                      ",".join([n.name for n in next_nodes]),
                  )
              )
          next_node = before
  
      if next_node is not None:
          next_node.inputs[input_idx] = node.outputs[0]
  
      new_graph = OrderedDict()
      for k, v in self.graph.items():
          new_graph[k] = v
          if k == prev_node.name:
              new_graph[node.name] = node
  
      self.graph = new_graph
      self._update_model_outputs()
  
imports: import ctypes
  import os
  import platform
  from collections import OrderedDict
  import numpy
  import numpy.ctypeslib
  from hls4ml.backends import get_backend
  from hls4ml.model.flow import get_flow
  from hls4ml.model.layers import layer_map
  from hls4ml.model.optimizer import get_available_passes, optimize_model
label_desc: Use image node_id 7 for calling the ModelGraph obj's underlying member method code with example usage: obj.insert_node(node, before, input_idx) without return types