code: def test_log_probability(X, shapes, rates):
      s, r = [1.7], [1.3]
      x = [[1.0], [2.0], [8.0], [3.0], [2.0]]
      y = [-0.758173, -1.57297, -8.402563, -2.589144, -1.57297]
  
      x_torch = torch.tensor(numpy.array(x))
      s_torch = torch.tensor(numpy.array(s))
      r_torch = torch.tensor(numpy.array(r))
  
      d1 = Gamma(s, r)
      d2 = Gamma(
          numpy.array(s, dtype=numpy.float64),
          numpy.array(r, dtype=numpy.float64),
      )
      d3 = torch.distributions.Gamma(s_torch, r_torch)
  
      _test_predictions(x, y, d1.log_probability(x), torch.float32)
      _test_predictions(x, y, d2.log_probability(x), torch.float64)
      _test_predictions(
          x,
          d3.log_prob(x_torch).sum(axis=1),
          d2.log_probability(x),
          torch.float64,
      )
  
      p = [1.7, 2.3, 1.0, 1.7, 4.1]
      x = [[1.0, 2.0, 8.0, 3.0, 2.0]]
      y = [-16.157602]
  
      p_torch = torch.tensor(numpy.array(p))
      x_torch = torch.tensor(numpy.array(x))
  
      d1 = Gamma(p, p)
      d2 = Gamma(
          numpy.array(p, dtype=numpy.float64),
          numpy.array(p, dtype=numpy.float64),
      )
      d3 = torch.distributions.Gamma(p_torch, p_torch)
  
      _test_predictions(x, y, d1.log_probability(x), torch.float32)
      _test_predictions(x, y, d2.log_probability(x), torch.float64)
      _test_predictions(
          x,
          d3.log_prob(x_torch).sum(axis=1),
          d2.log_probability(x),
          torch.float64,
      )
  
      p = [1, 2, 4]
      x = [[1, 2, 1], [2, 2, 1], [1, 1, 3], [2, 1, 2]]
      y = [-3.16714, -4.16714, -6.564451, -4.780846]
  
      p_torch = torch.tensor(numpy.array(p))
      x_torch = torch.tensor(numpy.array(x))
  
      d1 = Gamma(p, p)
      d2 = Gamma(
          numpy.array(p, dtype=numpy.float64),
          numpy.array(p, dtype=numpy.float64),
      )
      d3 = torch.distributions.Gamma(p_torch, p_torch)
  
      _test_predictions(x, y, d1.log_probability(x), torch.float32)
      _test_predictions(x, y, d2.log_probability(x), torch.float64)
      _test_predictions(
          x,
          d3.log_prob(x_torch).sum(axis=1),
          d2.log_probability(x),
          torch.float64,
      )
  
      p = [1.0, 2.0, 4.0]
      p_torch = torch.tensor(numpy.array(p))
  
      d1 = Gamma(p, p)
      d2 = Gamma(
          numpy.array(p, dtype=numpy.float64),
          numpy.array(p, dtype=numpy.float64),
      )
      d3 = torch.distributions.Gamma(p_torch, p_torch)
  
      _test_predictions(x, y, d1.log_probability(x), torch.float32)
      _test_predictions(x, y, d2.log_probability(x), torch.float64)
      _test_predictions(
          x,
          d3.log_prob(x_torch).sum(axis=1),
          d2.log_probability(x),
          torch.float64,
      )
  
      s_torch = torch.tensor(numpy.array(shapes))
      r_torch = torch.tensor(numpy.array(rates))
      x_torch = torch.tensor(numpy.array(X))
  
      y = [
          -6.504198,
          -2.381927,
          -4.373503,
          -7.307214,
          -4.473963,
          -8.848661,
          -5.889609,
      ]
  
      d1 = Gamma(shapes, rates)
      d2 = Gamma(
          numpy.array(shapes, dtype=numpy.float64),
          numpy.array(rates, dtype=numpy.float64),
      )
      d3 = torch.distributions.Gamma(s_torch, r_torch)
  
      _test_predictions(X, y, d1.log_probability(X), torch.float32)
      _test_predictions(X, y, d2.log_probability(X), torch.float64)
      _test_predictions(
          X,
          d3.log_prob(x_torch).sum(axis=1),
          d2.log_probability(X),
          torch.float64,
      )
  
imports: import os
  import numpy
  import torch
  import pytest
  from pomegranate.distributions import Gamma
  from ._utils import _test_initialization_raises_two_parameters
  from ._utils import _test_initialization
  from ._utils import _test_predictions
  from ._utils import _test_efd_from_summaries
  from ._utils import _test_raises
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 18 for calling a global function with example usage: test_log_probability(X, shapes, rates) without return types