```
def my_loss_fn(y_true, y_pred):
squared_difference = tf.math.abs(y_true - y_pred)
squared_difference=tf.math.reduce_sum(squared_difference,axis=-1)
return tf.reduce_mean(squared_difference, axis=-1)
```

*i want to build a custom loss function which checks only specific positions of a output tensor and based on some condition return the loss to optimizer*

Source: Python Questions