Would a loss function like below work: ?
def my_loss_func(y_hat, y):
   cnt = 0  
   for idx, val in  enumerate( y ) :
         if val != -1 : 
           s = s + val  - y_hat[idx]
           cnt  = cnt + 1 
   return s/cnt
 

Basically I want to take into account losses for only those values where the real answer is not equal to -1 (a value I fill the missing values with).
If not, any ideas on the correct way to approach this?