added calc_grad as part of code to find adversarial inputs. not tested