import torch


def generate_n_points(voxels, n, bounds):
    """
    Generate n random points within bounds, with voxels interpreted as pixels
    Args:
        voxels: The voxels
        n: How many points to generate
        bounds: (x_min, x_max, y_min, y_max, z_min, z_max) interpretation of the bounds for the voxels

    Returns:
        (points, points_occ)
    """
    x_min, x_max, y_min, y_max, z_min, z_max = bounds
    xs = torch.rand(n)
    ys = torch.rand(n)
    zs = torch.rand(n)
    points = torch.stack((xs * (x_max - x_min) + x_min,
                          ys * (y_max - y_min) + y_min,
                          zs * (z_max - z_min) + z_min), 1)
    x_dim, y_dim, z_dim = voxels.shape
    indices = (torch.floor(xs * x_dim).long(), torch.floor(ys * y_dim).long(), torch.floor(zs * z_dim).long())
    points_occ = voxels[indices] > 0.5
    return points, points_occ