code: def random_degree_sequence_graph(sequence, seed=None, tries=10):
      r"""Returns a simple random graph with the given degree sequence.
  
      If the maximum degree $d_m$ in the sequence is $O(m^{1/4})$ then the
      algorithm produces almost uniform random graphs in $O(m d_m)$ time
      where $m$ is the number of edges.
  
      Parameters
      ----------
      sequence :  list of integers
          Sequence of degrees
      seed : integer, random_state, or None (default)
          Indicator of random number generation state.
          See :ref:`Randomness<randomness>`.
      tries : int, optional
          Maximum number of tries to create a graph
  
      Returns
      -------
      G : Graph
          A graph with the specified degree sequence.
          Nodes are labeled starting at 0 with an index
          corresponding to the position in the sequence.
  
      Raises
      ------
      NetworkXUnfeasible
          If the degree sequence is not graphical.
      NetworkXError
          If a graph is not produced in specified number of tries
  
      See Also
      --------
      is_graphical, configuration_model
  
      Notes
      -----
      The generator algorithm [1]_ is not guaranteed to produce a graph.
  
      References
      ----------
      .. [1] Moshen Bayati, Jeong Han Kim, and Amin Saberi,
         A sequential algorithm for generating random graphs.
         Algorithmica, Volume 58, Number 4, 860-910,
         DOI: 10.1007/s00453-009-9340-1
  
      Examples
      --------
      >>> sequence = [1, 2, 2, 3]
      >>> G = nx.random_degree_sequence_graph(sequence, seed=42)
      >>> sorted(d for n, d in G.degree())
      [1, 2, 2, 3]
      """
      DSRG = DegreeSequenceRandomGraph(sequence, seed)
      for try_n in range(tries):
          try:
              return DSRG.generate()
          except nx.NetworkXUnfeasible:
              pass
      raise nx.NetworkXError(
          f"failed to generate graph in {tries} tries"
      )
  
imports: import heapq
  import math
  from itertools import chain, combinations, zip_longest
  from operator import itemgetter
  import networkx
  from networkx.utils import py_random_state, random_weighted_sample
label_desc: Use image node_id 9 for calling a global function with example usage: random_degree_sequence_graph(sequence, seed, tries) and returns: DSRG