code: def test_rejection_sample_basic(self):
      # Test without state names
      sample = self.sampling_inference.rejection_sample()
      sample = self.sampling_inference.rejection_sample(
          [State("A", 1), State("J", 1), State("R", 1)], int(1e5)
      )
      self.assertEqual(len(sample), int(1e5))
      self.assertEqual(len(sample.columns), 6)
      self.assertEqual(
          set(sample.columns), {"A", "J", "R", "Q", "G", "L"}
      )
      self.assertTrue(set(sample.A).issubset({1}))
      self.assertTrue(set(sample.J).issubset({1}))
      self.assertTrue(set(sample.R).issubset({1}))
      self.assertTrue(set(sample.Q).issubset({0, 1}))
      self.assertTrue(set(sample.G).issubset({0, 1}))
      self.assertTrue(set(sample.L).issubset({0, 1}))
  
      # Test that the marginal distributions is the same in model and samples
      self.rejection_marginals = VariableElimination(
          self.bayesian_model
      ).query(
          ["Q", "G", "L"],
          evidence={"A": 1, "J": 1, "R": 1},
          joint=False,
          show_progress=False,
      )
  
      sample_marginals = {
          node: sample[node].value_counts() / sample.shape[0]
          for node in ["Q", "G", "L"]
      }
  
      for node in ["Q", "G", "L"]:
          for state in [0, 1]:
              self.assertEqual(
                  round(
                      self.rejection_marginals[node].get_value(
                          **{node: state}
                      ),
                      1,
                  ),
                  round(sample_marginals[node].loc[state], 1),
              )
  
      # Test without state names with latent variables
      sample = self.sampling_inference_lat.rejection_sample(
          [State("A", 1), State("J", 1), State("R", 1)],
          25,
          include_latents=True,
      )
      self.assertEqual(len(sample), 25)
      self.assertEqual(len(sample.columns), 6)
      self.assertTrue(set(sample.A).issubset({1}))
      self.assertTrue(set(sample.J).issubset({1}))
      self.assertTrue(set(sample.R).issubset({1}))
      self.assertTrue(set(sample.Q).issubset({0, 1}))
      self.assertTrue(set(sample.G).issubset({0, 1}))
      self.assertTrue(set(sample.L).issubset({0, 1}))
  
      sample = self.sampling_inference_lat.rejection_sample(
          [State("A", 1), State("J", 1), State("R", 1)],
          25,
          include_latents=False,
      )
      self.assertEqual(len(sample), 25)
      self.assertEqual(len(sample.columns), 4)
      self.assertTrue(set(sample.A).issubset({1}))
      self.assertTrue(set(sample.J).issubset({1}))
      self.assertTrue(set(sample.G).issubset({0, 1}))
      self.assertTrue(set(sample.L).issubset({0, 1}))
  
      # Test with state names
      sample = self.sampling_inference_names.rejection_sample()
      sample = self.sampling_inference_names.rejection_sample(
          [State("A", "a1"), State("J", "j1"), State("R", "r1")], 25
      )
      self.assertEqual(len(sample), 25)
      self.assertEqual(len(sample.columns), 6)
      self.assertEqual(
          set(sample.columns), {"A", "J", "R", "Q", "G", "L"}
      )
      self.assertTrue(set(sample.A).issubset({"a1"}))
      self.assertTrue(set(sample.J).issubset({"j1"}))
      self.assertTrue(set(sample.R).issubset({"r1"}))
      self.assertTrue(set(sample.Q).issubset({"q0", "q1"}))
      self.assertTrue(set(sample.G).issubset({"g0", "g1"}))
      self.assertTrue(set(sample.L).issubset({"l0", "l1"}))
  
      # Test with state names and latent variables
      sample = self.sampling_inference_names_lat.rejection_sample(
          [State("A", "a1"), State("J", "j1"), State("R", "r1")],
          25,
          include_latents=True,
      )
      self.assertEqual(len(sample), 25)
      self.assertEqual(len(sample.columns), 6)
      self.assertEqual(
          set(sample.columns), {"A", "J", "R", "Q", "G", "L"}
      )
      self.assertTrue(set(sample.A).issubset({"a1"}))
      self.assertTrue(set(sample.J).issubset({"j1"}))
      self.assertTrue(set(sample.R).issubset({"r1"}))
      self.assertTrue(set(sample.Q).issubset({"q0", "q1"}))
      self.assertTrue(set(sample.G).issubset({"g0", "g1"}))
      self.assertTrue(set(sample.L).issubset({"l0", "l1"}))
  
      sample = self.sampling_inference_names_lat.rejection_sample(
          [State("A", "a1"), State("J", "j1"), State("R", "r1")],
          25,
          include_latents=False,
      )
      self.assertEqual(len(sample), 25)
      self.assertEqual(len(sample.columns), 4)
      self.assertEqual(set(sample.columns), {"A", "J", "G", "L"})
      self.assertTrue(set(sample.A).issubset({"a1"}))
      self.assertTrue(set(sample.J).issubset({"j1"}))
      self.assertTrue(set(sample.G).issubset({"g0", "g1"}))
      self.assertTrue(set(sample.L).issubset({"l0", "l1"}))
  
imports: import unittest
  import numpy
  from mock import MagicMock, patch
  from pgmpy.factors.discrete import DiscreteFactor, State, TabularCPD
  from pgmpy.inference import VariableElimination
  from pgmpy.models import BayesianNetwork, MarkovNetwork
  from pgmpy.sampling import BayesianModelSampling, GibbsSampling
  from pgmpy.sampling.base import BayesianModelInference
label_desc: Use image node_id 6 for calling the TestBayesianModelSampling obj's underlying member method code with example usage: obj.test_rejection_sample_basic() without return types