code: def test_factorset_marginalize_inplace(self):
      factor_set = FactorSet(self.phi1, self.phi2, self.phi3, self.phi4)
      factor_set.marginalize(["x1", "x5"], inplace=True)
      phi1_equivalent_in_factor_set = list(
          filter(
              lambda x: set(x.scope()) == {"x2", "x3"},
              factor_set.factors,
          )
      )[0]
      self.assertEqual(
          self.phi1.marginalize(["x1"], inplace=False),
          phi1_equivalent_in_factor_set,
      )
      phi2_equivalent_in_factor_set = list(
          filter(
              lambda x: set(x.scope()) == {"x4", "x3"},
              factor_set.factors,
          )
      )[0]
      self.assertEqual(
          self.phi2.marginalize(["x1"], inplace=False),
          phi2_equivalent_in_factor_set,
      )
      phi3_equivalent_in_factor_set = list(
          filter(
              lambda x: set(x.scope()) == {"x6", "x7"},
              factor_set.factors,
          )
      )[0]
      self.assertEqual(
          self.phi3.marginalize(["x5"], inplace=False),
          phi3_equivalent_in_factor_set,
      )
      phi4_equivalent_in_factor_set = list(
          filter(
              lambda x: set(x.scope()) == {"x8", "x7"},
              factor_set.factors,
          )
      )[0]
      self.assertEqual(
          self.phi4.marginalize(["x5"], inplace=False),
          phi4_equivalent_in_factor_set,
      )
  
file_path: pgmpy/pgmpy/tests/test_factors/test_FactorSet.py
imports: import unittest
  from pgmpy.factors import FactorSet
  from pgmpy.factors.discrete import DiscreteFactor
label_desc: Use image node_id 6 for calling the TestFactorSet obj's underlying member method code with example usage: obj.test_factorset_marginalize_inplace() without return types