code: def _serialize_quadratic_biases(quadratic, edgelist):
      
      # assumes quadratic is upper-triangular or reflected in edgelist
      quadratic_list = [quadratic[(u, v)] if (u, v) in quadratic else quadratic[(v, u)]
                        for u, v in edgelist]
      quadratic_bytes = struct.pack('<' + 'd' * len(quadratic), *quadratic_list)
      return base64.b64encode(quadratic_bytes).decode('utf-8')
docs: Serializes the quadratic biases.
  
      Args:
          quadratic (dict): a dict of the form {edge1: bias1, ...} where
              each edge is of the form (node1, node2).
          edgelist (list): a list of the form [(node1, node2), ...].
  
      Returns:
          str: base 64 encoded string of little endian 8 byte floats,
              one for each of the edges in quadratic. Ordered by edgelist.
  
      Example:
          >>> _serialize_quadratic_biases({(0, 1): -1, (1, 2): 1, (0, 2): .4},
          ...                             [(0, 1), (1, 2), (0, 2)])
          'AAAAAAAA8L8AAAAAAADwP5qZmZmZmdk/'