code: def test_add_marginal():
      m1 = Categorical([[0.5, 0.5]])
      m2 = Categorical([[0.5, 0.5]])
  
      model = FactorGraph()
      assert len(model.marginals) == 0
      assert model._marginal_idxs == {}
      assert model._marginal_edges == []
  
      model.add_marginal(m1)
      assert len(model.marginals) == 1
      assert model._marginal_idxs == {m1: 0}
      assert model._marginal_edges == [[]]
  
      model.add_marginal(m2)
      assert len(model.marginals) == 2
      assert model._marginal_idxs == {m1: 0, m2: 1}
      assert model._marginal_edges == [[], []]
  
imports: import numpy
  import torch
  import pytest
  from pomegranate.factor_graph import FactorGraph
  from pomegranate.distributions import Exponential
  from pomegranate.distributions import Categorical
  from pomegranate.distributions import JointCategorical
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 10 for calling a global function with example usage: test_add_marginal() without return types