This one is also not the right answer for my question. Right know I am trying to make a custom autograd function to optimize the binary masks but I have no idea how to calculate the forward and backward function in this case.