class_docstr: Class for performing inference using Belief Propagation method
  for the input Dynamic Bayesian Network.
  
  For the exact inference implementation, the interface algorithm
  is used which is adapted from [1].
  
  Parameters
  ----------
  model: Dynamic Bayesian Network
      Model for which inference is to performed
  
  Examples
  --------
  >>> from pgmpy.factors.discrete import TabularCPD
  >>> from pgmpy.models import DynamicBayesianNetwork as DBN
  >>> from pgmpy.inference import DBNInference
  >>> dbnet = DBN()
  >>> dbnet.add_edges_from([(('Z', 0), ('X', 0)), (('X', 0), ('Y', 0)),
  ...                       (('Z', 0), ('Z', 1))])
  >>> z_start_cpd = TabularCPD(('Z', 0), 2, [[0.5], [0.5]])
  >>> x_i_cpd = TabularCPD(('X', 0), 2, [[0.6, 0.9],
  ...                                    [0.4, 0.1]],
  ...                      evidence=[('Z', 0)],
  ...                      evidence_card=[2])
  >>> y_i_cpd = TabularCPD(('Y', 0), 2, [[0.2, 0.3],
  ...                                    [0.8, 0.7]],
  ...                      evidence=[('X', 0)],
  ...                      evidence_card=[2])
  >>> z_trans_cpd = TabularCPD(('Z', 1), 2, [[0.4, 0.7],
  ...                                        [0.6, 0.3]],
  ...                      evidence=[('Z', 0)],
  ...                      evidence_card=[2])
  >>> dbnet.add_cpds(z_start_cpd, z_trans_cpd, x_i_cpd, y_i_cpd)
  >>> dbnet.initialize_initial_state()
  >>> dbn_inf = DBNInference(dbnet)
  >>> dbn_inf.start_junction_tree.nodes()
  NodeView(((('X', 0), ('Y', 0)), (('X', 0), ('Z', 0))))
  >>> dbn_inf.one_and_half_junction_tree.nodes()
  NodeView(((('Z', 1), ('Z', 0)), (('Y', 1), ('X', 1)), (('Z', 1), ('X', 1))))
  
  References
  ----------
  [1] Dynamic Bayesian Networks: Representation, Inference and Learning
      by Kevin Patrick Murphy
      http://www.cs.ubc.ca/~murphyk/Thesis/thesis.pdf
class_docstr_tok: ["Class","for","performing","inference","using","Belief","Propagation","method","for","the","input","Dynamic","Bayesian","Network",".","For","the","exact","inference","implementation",",","the","interface","algorithm","is","used","which","is","adapted","from","[","1","]",".","Parameters","--","--","--","--","--","model",":","Dynamic","Bayesian","Network","Model","for","which","inference","is","to","performed","Examples","--","--","--","--",">",">",">","from","pgmpy.factors.discrete","import","TabularCPD",">",">",">","from","pgmpy.models","import","DynamicBayesianNetwork","as","DBN",">",">",">","from","pgmpy.inference","import","DBNInference",">",">",">","dbnet","=","DBN","(",")",">",">",">","dbnet.add_edges_from","(","[","(","(","'","Z","'",",","0",")",",","(","'","X","'",",","0",")",")",",","(","(","'","X","'",",","0",")",",","(","'","Y","'",",","0",")",")",",","...","(","(","'","Z","'",",","0",")",",","(","'","Z","'",",","1",")",")","]",")",">",">",">","z_start_cpd","=","TabularCPD","(","(","'","Z","'",",","0",")",",","2",",","[","[","0.5","]",",","[","0.5","]","]",")",">",">",">","x_i_cpd","=","TabularCPD","(","(","'","X","'",",","0",")",",","2",",","[","[","0.6",",","0.9","]",",","...","[","0.4",",","0.1","]","]",",","...","evidence=","[","(","'","Z","'",",","0",")","]",",","...","evidence_card=","[","2","]",")",">",">",">","y_i_cpd","=","TabularCPD","(","(","'","Y","'",",","0",")",",","2",",","[","[","0.2",",","0.3","]",",","...","[","0.8",",","0.7","]","]",",","...","evidence=","[","(","'","X","'",",","0",")","]",",","...","evidence_card=","[","2","]",")",">",">",">","z_trans_cpd","=","TabularCPD","(","(","'","Z","'",",","1",")",",","2",",","[","[","0.4",",","0.7","]",",","...","[","0.6",",","0.3","]","]",",","...","evidence=","[","(","'","Z","'",",","0",")","]",",","...","evidence_card=","[","2","]",")",">",">",">","dbnet.add_cpds","(","z_start_cpd",",","z_trans_cpd",",","x_i_cpd",",","y_i_cpd",")",">",">",">","dbnet.initialize_initial_state","(",")",">",">",">","dbn_inf","=","DBNInference","(","dbnet",")",">",">",">","dbn_inf.start_junction_tree.nodes","(",")","NodeView","(","(","(","(","'","X","'",",","0",")",",","(","'","Y","'",",","0",")",")",",","(","(","'","X","'",",","0",")",",","(","'","Z","'",",","0",")",")",")",")",">",">",">","dbn_inf.one_and_half_junction_tree.nodes","(",")","NodeView","(","(","(","(","'","Z","'",",","1",")",",","(","'","Z","'",",","0",")",")",",","(","(","'","Y","'",",","1",")",",","(","'","X","'",",","1",")",")",",","(","(","'","Z","'",",","1",")",",","(","'","X","'",",","1",")",")",")",")","References","--","--","--","--","--","[","1","]","Dynamic","Bayesian","Networks",":","Representation",",","Inference","and","Learning","by","Kevin","Patrick","Murphy","http",":","\/\/www.cs.ubc.ca\/~murphyk\/Thesis\/thesis.pdf"]
docstr: Query method for Dynamic Bayesian Network using Interface Algorithm.
  
  Parameters
  ----------
  variables: list
      list of variables for which you want to compute the probability
  
  evidence: dict
      a dict key, value pair as {var: state_of_var_observed}
      None if no evidence
  
  Examples
  --------
  >>> from pgmpy.factors.discrete import TabularCPD
  >>> from pgmpy.models import DynamicBayesianNetwork as DBN
  >>> from pgmpy.inference import DBNInference
  >>> dbnet = DBN()
  >>> dbnet.add_edges_from([(('Z', 0), ('X', 0)), (('X', 0), ('Y', 0)),
  ...                       (('Z', 0), ('Z', 1))])
  >>> z_start_cpd = TabularCPD(('Z', 0), 2, [[0.5], [0.5]])
  >>> x_i_cpd = TabularCPD(('X', 0), 2, [[0.6, 0.9],
  ...                                    [0.4, 0.1]],
  ...                      evidence=[('Z', 0)],
  ...                      evidence_card=[2])
  >>> y_i_cpd = TabularCPD(('Y', 0), 2, [[0.2, 0.3],
  ...                                    [0.8, 0.7]],
  ...                      evidence=[('X', 0)],
  ...                      evidence_card=[2])
  >>> z_trans_cpd = TabularCPD(('Z', 1), 2, [[0.4, 0.7],
  ...                                        [0.6, 0.3]],
  ...                      evidence=[('Z', 0)],
  ...                      evidence_card=[2])
  >>> dbnet.add_cpds(z_start_cpd, z_trans_cpd, x_i_cpd, y_i_cpd)
  >>> dbnet.initialize_initial_state()
  >>> dbn_inf = DBNInference(dbnet)
  >>> dbn_inf.query([('X', 0)], {('Y', 0):0, ('Y', 1):1, ('Y', 2):1})[('X', 0)].values
  array([0.66594382, 0.33405618])
docstr_tok: ["Query","method","for","Dynamic","Bayesian","Network","using","Interface","Algorithm",".","Parameters","--","--","--","--","--","variables",":","list","list","of","variables","for","which","you","want","to","compute","the","probability","evidence",":","dict","a","dict","key",",","value","pair","as","{","var",":","state_of_var_observed","}","None","if","no","evidence","Examples","--","--","--","--",">",">",">","from","pgmpy.factors.discrete","import","TabularCPD",">",">",">","from","pgmpy.models","import","DynamicBayesianNetwork","as","DBN",">",">",">","from","pgmpy.inference","import","DBNInference",">",">",">","dbnet","=","DBN","(",")",">",">",">","dbnet.add_edges_from","(","[","(","(","'","Z","'",",","0",")",",","(","'","X","'",",","0",")",")",",","(","(","'","X","'",",","0",")",",","(","'","Y","'",",","0",")",")",",","...","(","(","'","Z","'",",","0",")",",","(","'","Z","'",",","1",")",")","]",")",">",">",">","z_start_cpd","=","TabularCPD","(","(","'","Z","'",",","0",")",",","2",",","[","[","0.5","]",",","[","0.5","]","]",")",">",">",">","x_i_cpd","=","TabularCPD","(","(","'","X","'",",","0",")",",","2",",","[","[","0.6",",","0.9","]",",","...","[","0.4",",","0.1","]","]",",","...","evidence=","[","(","'","Z","'",",","0",")","]",",","...","evidence_card=","[","2","]",")",">",">",">","y_i_cpd","=","TabularCPD","(","(","'","Y","'",",","0",")",",","2",",","[","[","0.2",",","0.3","]",",","...","[","0.8",",","0.7","]","]",",","...","evidence=","[","(","'","X","'",",","0",")","]",",","...","evidence_card=","[","2","]",")",">",">",">","z_trans_cpd","=","TabularCPD","(","(","'","Z","'",",","1",")",",","2",",","[","[","0.4",",","0.7","]",",","...","[","0.6",",","0.3","]","]",",","...","evidence=","[","(","'","Z","'",",","0",")","]",",","...","evidence_card=","[","2","]",")",">",">",">","dbnet.add_cpds","(","z_start_cpd",",","z_trans_cpd",",","x_i_cpd",",","y_i_cpd",")",">",">",">","dbnet.initialize_initial_state","(",")",">",">",">","dbn_inf","=","DBNInference","(","dbnet",")",">",">",">","dbn_inf.query","(","[","(","'","X","'",",","0",")","]",",","{","(","'","Y","'",",","0",")",":0",",","(","'","Y","'",",","1",")",":1",",","(","'","Y","'",",","2",")",":1","}",")","[","(","'","X","'",",","0",")","]",".values","array","(","[","0.66594382",",","0.33405618","]",")"]
code: def query(self, variables, evidence=None, args="exact"):
      """
      Query method for Dynamic Bayesian Network using Interface Algorithm.
  
      Parameters
      ----------
      variables: list
          list of variables for which you want to compute the probability
  
      evidence: dict
          a dict key, value pair as {var: state_of_var_observed}
          None if no evidence
  
      Examples
      --------
      >>> from pgmpy.factors.discrete import TabularCPD
      >>> from pgmpy.models import DynamicBayesianNetwork as DBN
      >>> from pgmpy.inference import DBNInference
      >>> dbnet = DBN()
      >>> dbnet.add_edges_from([(('Z', 0), ('X', 0)), (('X', 0), ('Y', 0)),
      ...                       (('Z', 0), ('Z', 1))])
      >>> z_start_cpd = TabularCPD(('Z', 0), 2, [[0.5], [0.5]])
      >>> x_i_cpd = TabularCPD(('X', 0), 2, [[0.6, 0.9],
      ...                                    [0.4, 0.1]],
      ...                      evidence=[('Z', 0)],
      ...                      evidence_card=[2])
      >>> y_i_cpd = TabularCPD(('Y', 0), 2, [[0.2, 0.3],
      ...                                    [0.8, 0.7]],
      ...                      evidence=[('X', 0)],
      ...                      evidence_card=[2])
      >>> z_trans_cpd = TabularCPD(('Z', 1), 2, [[0.4, 0.7],
      ...                                        [0.6, 0.3]],
      ...                      evidence=[('Z', 0)],
      ...                      evidence_card=[2])
      >>> dbnet.add_cpds(z_start_cpd, z_trans_cpd, x_i_cpd, y_i_cpd)
      >>> dbnet.initialize_initial_state()
      >>> dbn_inf = DBNInference(dbnet)
      >>> dbn_inf.query([('X', 0)], {('Y', 0):0, ('Y', 1):1, ('Y', 2):1})[('X', 0)].values
      array([0.66594382, 0.33405618])
      """
      if args == "exact":
          return self.backward_inference(variables, evidence)
  
file_path: pgmpy/pgmpy/inference/dbn_inference.py
imports: from collections import defaultdict
  from itertools import chain, combinations, tee
  from pgmpy.factors import factor_product
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.inference import BeliefPropagation, Inference
label_desc: Use image node_id 11 for calling the DBNInference obj's underlying member method code with example usage: obj.query(variables, evidence, args) and returns: self