def METHOD_NAME(
    rv_var, obs, dist_params, test_fn=None, check_broadcastable=True, test="logprob"
):
    """Test for correspondence between `RandomVariable` and NumPy shape and
    broadcast dimensions.
    """
    if test_fn is None:
        name = getattr(rv_var.owner.op, "name", None)
        if name is None:
            name = rv_var.__name__
        test_fn = getattr(stats, name)
    if test == "logprob":
        pytensor_res = logp(rv_var, pt.as_tensor(obs))
    elif test == "logcdf":
        pytensor_res = logcdf(rv_var, pt.as_tensor(obs))
    elif test == "icdf":
        pytensor_res = icdf(rv_var, pt.as_tensor(obs))
    else:
        raise ValueError(f"test must be one of (logprob, logcdf, icdf), got {test}")
    pytensor_res_val = pytensor_res.eval(dist_params)
    numpy_res = np.asarray(test_fn(obs, *dist_params.values()))
    assert pytensor_res.type.numpy_dtype.kind == numpy_res.dtype.kind
    if check_broadcastable:
        numpy_shape = np.shape(numpy_res)
        numpy_bcast = [s == 1 for s in numpy_shape]
        np.testing.assert_array_equal(pytensor_res.type.broadcastable, numpy_bcast)
    np.testing.assert_array_equal(pytensor_res_val.shape, numpy_res.shape)
    np.testing.assert_array_almost_equal(pytensor_res_val, numpy_res, 4)