https://github.com/dhruvdcoder/structured_prediction_baselines/blob/cf7dbf23439c9cc817eebe25545c25b0cf7dfd9f/structured_prediction_baselines/modules/loss/dvn.py#L184-L186 https://github.com/dhruvdcoder/structured_prediction_baselines/blob/cf7dbf23439c9cc817eebe25545c25b0cf7dfd9f/structured_prediction_baselines/modules/loss/dvn.py#L322 This violates the base-class return type-- the caller has to implement an if condition. The solution is to generalize the base-class function signature.