code: def test_simulate_evidence_two_slices(self):
      # Single evidence
      samples = self.dbn.simulate(
          n_samples=int(1e5),
          n_time_slices=2,
          evidence={("D", 0): 1},
          show_progress=False,
      )
      self.assertEqual(len(samples), int(1e5))
      self.assertEqual(len(samples.columns), 6)
      for node in [
          ("D", 0),
          ("I", 0),
          ("G", 0),
          ("D", 1),
          ("I", 1),
          ("G", 1),
      ]:
          self.assertIn(node, samples.columns)
  
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("D", 0)]].values)), [1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("I", 0)]].values)), [0, 1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("G", 0)]].values)),
          [0, 1, 2],
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("D", 1)]].values)), [0, 1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("I", 1)]].values)), [0, 1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("G", 1)]].values)),
          [0, 1, 2],
      )
  
      # Test the asymptotic distribution of samples
      sample_marginals = {
          node: samples.loc[:, [node.to_tuple()]].value_counts()
          / samples.shape[0]
          for node in self.dbn.nodes()
      }
  
      for node in sample_marginals.keys():
          samples_cpd = sample_marginals[node]
          # DBN query only works for variables > evidence time
          if node[1] > 0:
              dbn_infer_cpd = self.dbn_infer.query(
                  [node], evidence={("D", 0): 1}
              )[node]
          # Query can't have same node in variables and evidence
          if node != ("D", 0):
              bn_infer_cpd = self.bn_infer.query(
                  [str(node[0]) + str(node[1])], evidence={"D0": 1}
              )
  
          for state in range(samples_cpd.shape[0]):
              # TODO: DBN query with evidence values doesn't match with BN inference or sampling
              # if node[1] > 0:
              #     self.assertTrue(
              #         np.isclose(
              #             sample_marginals[node].loc[state].values[0],
              #             dbn_infer_cpd.values[state],
              #             atol=0.01,
              #         )
              #     )
              if node != ("D", 0):
                  self.assertTrue(
                      np.isclose(
                          sample_marginals[node].loc[state].values[0],
                          bn_infer_cpd.values[state],
                          atol=0.01,
                      )
                  )
  
      samples = self.dbn.simulate(
          n_samples=int(1e5),
          n_time_slices=2,
          evidence={
              ("D", 0): 1,
              ("D", 1): 0,
          },
          show_progress=False,
      )
      self.assertEqual(len(samples), int(1e5))
      self.assertEqual(len(samples.columns), 6)
      for node in [
          ("D", 0),
          ("I", 0),
          ("G", 0),
          ("D", 1),
          ("I", 1),
          ("G", 1),
      ]:
          self.assertIn(node, samples.columns)
  
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("D", 0)]].values)), [1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("I", 0)]].values)), [0, 1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("G", 0)]].values)),
          [0, 1, 2],
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("D", 1)]].values)), [0]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("I", 1)]].values)), [0, 1]
      )
      self.assertTrue(
          sorted(np.unique(samples.loc[:, [("G", 1)]].values)),
          [0, 1, 2],
      )
  
      # Test the asymptotic distribution of samples
      sample_marginals = {
          node: samples.loc[:, [node.to_tuple()]].value_counts()
          / samples.shape[0]
          for node in self.dbn.nodes()
      }
  
      for node in sample_marginals.keys():
          samples_cpd = sample_marginals[node]
          # Query can't have same node in variables and evidence
          if node not in [("D", 0), ("D", 1)]:
              bn_infer_cpd = self.bn_infer.query(
                  [str(node[0]) + str(node[1])],
                  evidence={"D0": 1, "D1": 0},
              )
  
          for state in range(samples_cpd.shape[0]):
              if node not in [("D", 0), ("D", 1)]:
                  self.assertTrue(
                      np.isclose(
                          sample_marginals[node].loc[state].values[0],
                          bn_infer_cpd.values[state],
                          atol=0.01,
                      )
                  )
  
imports: import unittest
  import numpy
  import numpy.testing
  import pandas
  import pgmpy.tests.help_functions
  from pgmpy.factors.discrete import TabularCPD
  from pgmpy.inference import CausalInference, DBNInference, VariableElimination
  from pgmpy.models import BayesianNetwork
  from pgmpy.models import DynamicBayesianNetwork
label_desc: Use image node_id 4 for calling the TestDBNSampling obj's underlying member method code with example usage: obj.test_simulate_evidence_two_slices() without return types