main_tensor / length_tensor.view(20, 1) should do the trick.
You’d like to divide each element of main_tensor[i] by length_tensor[i]. The key is broadcasting length_tensor to match the size of main_tensor so that we can do element-wise division.