code: def generate(self):
      # remaining_degree is mapping from int->remaining degree
      self.remaining_degree = dict(enumerate(self.degree))
      # add all nodes to make sure we get isolated nodes
      self.graph = nx.Graph()
      self.graph.add_nodes_from(self.remaining_degree)
      # remove zero degree nodes
      for n, d in list(self.remaining_degree.items()):
          if d == 0:
              del self.remaining_degree[n]
      if len(self.remaining_degree) > 0:
          # build graph in three phases according to how many unmatched edges
          self.phase1()
          self.phase2()
          self.phase3()
      return self.graph
  
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 2 for calling the DegreeSequenceRandomGraph obj's underlying member method code with example usage: obj.generate() and returns: self