code: def test_hmm_forward_backward(hmm, X, priors):
      X = numpy.array([X])
      priors = priors.unsqueeze(0)
  
      t, r, starts, ends, logp = hmm.forward_backward(X)
      assert_array_almost_equal(
          t, [[[1.8028e-03, 2.2629e00], [3.1568e00, 4.5785e00]]], 4
      )
  
      assert_array_almost_equal(
          r,
          [
              [
                  [-2.3343e00, -1.0190e-01],
                  [-5.5721e00, -3.8109e-03],
                  [-1.8306e01, 0.0000e00],
                  [-1.9578e01, 0.0000e00],
                  [-2.7591e-01, -1.4225e00],
                  [-3.3558e01, 0.0000e00],
                  [-3.2527e-01, -1.2813e00],
                  [-1.2301e01, -3.8147e-06],
                  [-3.8184e-01, -1.1476e00],
                  [-8.7126e00, -1.6403e-04],
                  [-9.1934e-03, -4.6938e00],
              ]
          ],
          3,
      )
  
      assert_array_almost_equal(starts, [[0.0969, 0.9031]], 4)
      assert_array_almost_equal(ends, [[0.9908, 0.0092]], 4)
      assert_array_almost_equal(logp, [-42.9108], 4)
  
      t, r, starts, ends, logp = hmm.forward_backward(X, priors=priors)
      assert_array_almost_equal(
          t, [[[0.9999, 1.6556], [2.5572, 4.7872]]], 4
      )
  
      assert_array_almost_equal(
          r,
          [
              [
                  [-2.3343e00, -1.0190e-01],
                  [-5.5721e00, -3.8109e-03],
                  [-1.8306e01, 0.0000e00],
                  [-inf, 0.0000e00],
                  [-2.7591e-01, -1.4225e00],
                  [-3.4329e01, 0.0000e00],
                  [-2.2815e-01, -1.5897e00],
                  [-1.3709e01, 0.0000e00],
                  [-inf, 0.0000e00],
                  [0.0000e00, -inf],
                  [-1.5373e-03, -6.4778e00],
              ]
          ],
          3,
      )
  
      assert_array_almost_equal(starts, [[0.0969, 0.9031]], 4)
      assert_array_almost_equal(ends, [[0.9985, 0.0015]], 4)
      assert_array_almost_equal(logp, [-59.3789], 4)
  
imports: import os
  import numpy
  import torch
  import pytest
  from pomegranate.gmm import GeneralMixtureModel
  from pomegranate.hmm import DenseHMM
  from pomegranate.distributions import Exponential
  from nose.tools import assert_raises
  from numpy.testing import assert_array_equal
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 29 for calling a global function with example usage: test_hmm_forward_backward(hmm, X, priors) without return types