I don’t think there is need to do so. But you check the value of labels.dtpe with and without float().
Why convert to float? I don’t think there is any important reason, maybe the method they implement under the hood requires these values to be in float. In PyTorch 1.3 type promotion was updated so I think we can leave this step also.