def _get_p_from_g(self, cg_id, g, params): """ Utility function to pick the parameter given gradient. """ p_name = re.search('\(dcost_' + cg_id + '/d(.+?)\)', g.name).group(1) return params[p_name]