deep learning for computer vision function that takes numpy tensor (as list of tensors of size and returns list of two numpy tensorsthe loss value and the gradient value listing fet ching numpy out put values given numpy input values iterate function([model input][lossgrads]import numpy as np loss_valuegrads_value iterate([np zeros(( ))]at this pointyou can define python loop to do stochastic gradient descent listing loss maximizat ion via st ochast ic gradient descent starts from gray image with some noise input_img_data np random random(( ) step magnitude of each gradient update for in range( )loss_valuegrads_value iterate([input_img_data]input_img_data +grads_value step computes the loss value and gradient value runs gradient ascent for steps adjusts the input image in the direction that maximizes the loss the resulting image tensor is floating-point tensor of shape ( )with values that may not be integers within [ henceyou need to postprocess this tensor to turn it into displayable image you do so with the following straightforward utility function listing ut ilit function convert ensor int valid image def deprocess_image( ) - mean( /( std( - * + np clip( normalizes the tensorcenters on ensures that std is clips to [ * np clip( astype('uint 'return converts to an rgb array now you have all the pieces let' put them together into python function that takes as input layer name and filter indexand returns valid image tensor representing the pattern that maximizes the activation of the specified filter licensed to