code: def test_generic_log_prob(case, use_lazy):
      raw_dist = case.get_dist()
      expected_value_domain = case.expected_value_domain
  
      dim_to_name, name_to_dim = _default_dim_to_name(
          raw_dist.batch_shape
      )
      with eager_no_dists if use_lazy else eager:
          with xfail_if_not_implemented(match="try upgrading backend"):
              # some distributions have nontrivial eager patterns
              funsor_dist = to_funsor(
                  raw_dist, output=funsor.Real, dim_to_name=dim_to_name
              )
      expected_inputs = {
          name: funsor.Bint[raw_dist.batch_shape[dim]]
          for dim, name in dim_to_name.items()
      }
      expected_inputs.update({"value": expected_value_domain})
  
      check_funsor(funsor_dist, expected_inputs, funsor.Real)
  
      if get_backend() == "jax":
          raw_value = raw_dist.sample(
              key=np.array([0, 0], dtype=np.uint32)
          )
      else:
          raw_value = raw_dist.sample()
      expected_logprob = to_funsor(
          raw_dist.log_prob(raw_value),
          output=funsor.Real,
          dim_to_name=dim_to_name,
      )
      funsor_value = to_funsor(
          raw_value,
          output=expected_value_domain,
          dim_to_name=dim_to_name,
      )
      assert_close(
          funsor_dist(value=funsor_value), expected_logprob, rtol=1e-3
      )
  
imports: import re
  from collections import OrderedDict, namedtuple
  from importlib import import_module
  import numpy
  import pytest
  import funsor
  import funsor.ops
  from funsor.distribution import BACKEND_TO_DISTRIBUTIONS_BACKEND
  from funsor.interpretations import CallableInterpretation, eager, lazy, normalize, reflect
  from funsor.terms import to_data, to_funsor
  from funsor.testing import assert_close, check_funsor, excludes_backend, rand, randint, randn, random_scale_tril, xfail_if_not_found, xfail_if_not_implemented, xfail_param
  from funsor.util import get_backend
label_desc: Use image node_id 4 for calling a global function with example usage: test_generic_log_prob(case, use_lazy) without return types