code: def test_shapes(batch_dim, event_dim, has_log_density):
      shape = tuple(range(2, 2 + batch_dim + event_dim))
      batch_shape = shape[:batch_dim]
      v = torch.randn(shape)
      log_density = torch.randn(batch_shape) if has_log_density else 0
  
      d = dist.Delta(v, log_density=log_density, event_dim=event_dim)
      x = d.rsample()
      assert (x == v).all()
      assert (d.log_prob(x) == log_density).all()
  
file_path: pyro/tests/distributions/test_delta.py
imports: from unittest import TestCase
  import numpy
  import pytest
  import torch
  import pyro.distributions
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_shapes(batch_dim, event_dim, has_log_density) without return types