Hello There?
I want to use 3rd party lib when define loss function , because pytorch can not fulfill all requirments for users ,pseudo code as following:
from shapely.geometry import Polygon  # 3rd party pacakage

p1=Polygon(polygon_from_model_inference)
p2=Polygon(polygon_ground_truth)
intersection_area=p1.intersection(p2).area
iou=intersection_area/(p1.area+p2.area-intersection_area)
loss= iou

Whether pytoch will automatically trace the gradient of “loss” or not ? Thank you in advance