code: def test_categorical_log_prob(sample_shape, batch_shape, cardinality):
      logits = torch.randn(batch_shape + (cardinality,))
      logits -= logits.logsumexp(dim=-1, keepdim=True)
      actual = Categorical(logits=logits)
      expected = dist.Categorical(logits=logits)
      assert actual.batch_shape == expected.batch_shape
      assert actual.event_shape == expected.event_shape
  
      value = expected.sample(sample_shape)
      actual_log_prob = actual.log_prob(value)
      expected_log_prob = expected.log_prob(value)
      assert_close(actual_log_prob, expected_log_prob)
  
file_path: funsor/test/pyro/test_distribution.py
imports: import pyro.distributions
  import pytest
  import torch
  from funsor.pyro.convert import tensor_to_funsor
  from funsor.pyro.distribution import FunsorDistribution
  from funsor.testing import assert_close
label_desc: Use image node_id 1 for calling a global function with example usage: test_categorical_log_prob(sample_shape, batch_shape, cardinality) without return types