def gaussian_kernel(D, 
                    sigma):
    """
    Applies Gaussian kernel element-wise.
    
    Computes exp(-d / (2 * (sigma ^ 2))) for each element d in D.
    
    Parameters
    ----------
    
    D: torch tensor
        
    sigma: scalar
        Gaussian kernel width.
        
    Returns
    -------
    
    torch tensor
        Result of applying Gaussian kernel to D element-wise.          
    """
    
    return (-D / (2 * (sigma ** 2))).exp()