class_docstr: A Directed Acyclic Graph
class_docstr_tok: ["A","Directed","Acyclic","Graph"]
docstr: query is a dict of currently evidenced
  variables and is none by default.
docstr_tok: ["query","is","a","dict","of","currently","evidenced","variables","and","is","none","by","default","."]
code: def draw_samples(self, query={}, n=1):
      """query is a dict of currently evidenced
      variables and is none by default."""
      samples = []
      result_cache = {}
      # We need to add evidence variables to the sample...
      while len(samples) < n:
          sample = dict(query)
          while len(sample) < len(self.nodes):
              next_node = choice(
                  [
                      node
                      for node in self.nodes
                      if node.variable_name not in sample
                  ]
              )
              key = tuple(sorted(sample.items()))
              if key not in result_cache:
                  result_cache[key] = self.query(**sample)
              result = result_cache[key]
              var_density = [
                  r
                  for r in list(result.items())
                  if r[0][0] == next_node.variable_name
              ]
              cumulative_density = var_density[:1]
              for key, mass in var_density[1:]:
                  cumulative_density.append(
                      (key, cumulative_density[-1][1] + mass)
                  )
              r = random()
              i = 0
              while r > cumulative_density[i][1]:
                  i += 1
              sample[next_node.variable_name] = cumulative_density[i][
                  0
              ][1]
          samples.append(sample)
      return samples
  
imports: import copy
  import heapq
  import logging
  from collections import defaultdict
  from io import StringIO
  from itertools import combinations, product
  from random import choice, random
  from .exceptions import VariableNotInGraphError, VariableValueNotInDomainError
  from .graph import Node, UndirectedGraph, UndirectedNode, connect
  from .utils import get_args, get_original_factors
label_desc: Use image node_id 6 for calling the BBN obj's underlying member method code with example usage: obj.draw_samples(query, n) and returns: samples