You could use np.digitize to create the indices of the bins and then use the one_hot method as seen here:
x = np.array([ 0.0379, -0.0372,  0.0277, -0.1918, -0.0679,  0.0858,  0.0655,  0.2807,
              -0.1375, -0.0066,  0.1309,  0.0893,  0.0757,  0.1891,  0.2998, -0.1810,
              -0.0809,  0.1543, -0.0852, -0.1351,  0.0900, -0.1985, -0.0525,  0.0582,
              0.0410,  0.3986,  0.3757,  0.2447, -0.3319, -0.2319, -0.0495, -0.0034])

bins = np.linspace(x.min(), x.max(), 100)
y = np.digitize(x, bins) - 1
y = torch.from_numpy(y)
one_hot = torch.nn.functional.one_hot(y, num_classes=100)