code: def getSparseWeights(weightSparsity, inputSize, outputSize):
    
    # Initialize weights in the typical fashion.
    w = torch.Tensor(outputSize, inputSize)
    stdv = 1. / math.sqrt(w.size(1))
    w.data.uniform_(-stdv, stdv)
  
    numZeros = int(round((1.0 - weightSparsity) * inputSize))
  
    outputIndices = np.arange(outputSize)
    inputIndices = np.array([np.random.permutation(inputSize)[:numZeros]
                             for _ in outputIndices], dtype=np.long)
  
    # Create tensor indices for all non-zero weights
    zeroIndices = np.empty((outputSize, numZeros, 2), dtype=np.long)
    zeroIndices[:, :, 0] = outputIndices[:, None]
    zeroIndices[:, :, 1] = inputIndices
    zeroIndices = torch.LongTensor(zeroIndices.reshape(-1, 2))
  
    zeroWts = (zeroIndices[:, 0], zeroIndices[:, 1])
    w.data[zeroWts] = 0.0
  
    return w
docs: Return a randomly initialized weight matrix
    Size is outputSize X inputSize, with sparsity weightSparsity%