def warp(img, tx, dsize=None)
""" Warp img using tx, a matrix representing a geometric transformation.
Pre: tx is 3x3 (or some upper-left slice of a 3x3 matrix). img is grayscale.
Returns: an output image of shape dsize with the warped img"""
H, W = img.shape[:2]
# turn a 2x2 or 2x3 tx into a full 3x3 matrix
txH, txW = tx.shape
M = np.eye(3)
M[:txH,:txW] = tx
# set the output size to the input size if not specified
if dsize is None:
DH, DW = (H, W)
else:
DH, DW = dsize[::-1]
out = np.zeros((DH, DW))
# your code here
return outimg after it
has been warped using a homography T.Use the chain rule to break down the problem as follows: * \(\frac{\partial \mathcal{L}}{\partial w} = \frac{\partial }{\partial \hat{y_i}} \left[ \frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y_i})^2\right] \cdot \frac{\partial}{\partial w} \hat{y_i}\) =