Gradient Based Optimization Code Python Hinh