Program: 3214
Project: 3214
Buggy source:
/** 
 * @param wrt
 * @param epsilon
 * @param maxRelError
 * @param minAbsoluteError
 * @param print
 * @param exitOnFirstError
 * @param inputParameters
 * @param rngSeed
 * @return
 */
public static boolean checkGradients(TensorGradVariable wrt,double epsilon,double maxRelError,double minAbsoluteError,boolean print,boolean exitOnFirstError,Map<String,INDArray> inputParameters,int rngSeed){
  if (epsilon <= 0.0 || epsilon > 0.1)   throw new IllegalArgumentException("String_Node_Str");
  if (maxRelError <= 0.0 || maxRelError > 0.25)   throw new IllegalArgumentException("String_Node_Str" + maxRelError);
  DataBuffer.Type dataType=DataTypeUtil.getDtypeFromContext();
  if (dataType != DataBuffer.Type.DOUBLE) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + dataType + "String_Node_Str"+ "String_Node_Str");
  }
  TensorGrad tensorGrad=wrt.getTensorGrad();
  int totalNFailures=0;
  double maxError=0.0;
  for (  Map.Entry<String,INDArray> entry : inputParameters.entrySet()) {
    int nParams=entry.getValue().length();
    INDArray params=entry.getValue().dup();
    for (int i=0; i < nParams; i++) {
      double origValue=params.getDouble(i);
      params.putScalar(i,origValue + epsilon);
      Map<String,INDArray> evalParams=new HashMap<>();
      for (      Map.Entry<String,INDArray> entry2 : inputParameters.entrySet()) {
        if (!entry2.getKey().equals(entry.getKey())) {
          evalParams.put(entry2.getKey(),entry2.getValue());
        }
 else {
          evalParams.put(entry.getKey(),params);
        }
      }
      INDArray[] plusParams=tensorGrad.eval(evalParams);
      params.putScalar(i,origValue - epsilon);
      INDArray[] minusParams=tensorGrad.eval(evalParams);
      Nd4j.getRandom().setSeed(rngSeed);
      INDArray[] newDifferences=new INDArray[minusParams.length];
      for (int j=0; j < newDifferences.length; j++) {
        newDifferences[i]=plusParams[i].subi(minusParams[i]).divi(epsilon);
      }
      double scoreDelta=0.0;
      for (      INDArray arr : newDifferences)       scoreDelta+=arr.sumNumber().doubleValue();
      params.putScalar(i,origValue);
      double numericalGradient=scoreDelta / (2 * epsilon);
      if (Double.isNaN(numericalGradient))       throw new IllegalStateException("String_Node_Str" + i + "String_Node_Str"+ nParams);
      if (print) {
        int nPass=nParams - totalNFailures;
        log.info("String_Node_Str" + nParams + "String_Node_Str"+ nPass+ "String_Node_Str"+ totalNFailures+ "String_Node_Str"+ maxError);
      }
    }
  }
  return totalNFailures == 0;
}

Fixed version (ground truth):
/** 
 * @param wrt
 * @param epsilon
 * @param maxRelError
 * @param minAbsoluteError
 * @param print
 * @param exitOnFirstError
 * @param inputParameters
 * @param rngSeed
 * @return
 */
public static boolean checkGradients(TensorGradVariable wrt,TensorGradVariable function,double epsilon,double maxRelError,double minAbsoluteError,boolean print,boolean exitOnFirstError,Map<String,INDArray> inputParameters,int rngSeed){
  if (epsilon <= 0.0 || epsilon > 0.1)   throw new IllegalArgumentException("String_Node_Str");
  if (maxRelError <= 0.0 || maxRelError > 0.25)   throw new IllegalArgumentException("String_Node_Str" + maxRelError);
  DataBuffer.Type dataType=DataTypeUtil.getDtypeFromContext();
  if (dataType != DataBuffer.Type.DOUBLE) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + dataType + "String_Node_Str"+ "String_Node_Str");
  }
  TensorGrad tensorGrad=wrt.getTensorGrad();
  TensorGradVariable variable=tensorGrad.grad(function,wrt);
  int totalNFailures=0;
  double maxError=0.0;
  for (  Map.Entry<String,INDArray> entry : inputParameters.entrySet()) {
    int nParams=entry.getValue().length();
    INDArray params=entry.getValue().dup();
    for (int i=0; i < nParams; i++) {
      double origValue=params.getDouble(i);
      params.putScalar(i,origValue + epsilon);
      Map<String,INDArray> evalParams=new HashMap<>();
      for (      Map.Entry<String,INDArray> entry2 : inputParameters.entrySet()) {
        if (!entry2.getKey().equals(entry.getKey())) {
          evalParams.put(entry2.getKey(),entry2.getValue());
        }
 else {
          evalParams.put(entry.getKey(),params);
        }
      }
      INDArray[] plusParams=tensorGrad.eval(evalParams);
      params.putScalar(i,origValue - epsilon);
      INDArray[] minusParams=tensorGrad.eval(evalParams);
      Nd4j.getRandom().setSeed(rngSeed);
      INDArray[] newDifferences=new INDArray[minusParams.length];
      for (int j=0; j < newDifferences.length; j++) {
        newDifferences[i]=plusParams[i].subi(minusParams[i]).divi(epsilon);
      }
      double scoreDelta=0.0;
      for (      INDArray arr : newDifferences)       scoreDelta+=arr.sumNumber().doubleValue();
      params.putScalar(i,origValue);
      double numericalGradient=scoreDelta / (2 * epsilon);
      if (Double.isNaN(numericalGradient))       throw new IllegalStateException("String_Node_Str" + i + "String_Node_Str"+ nParams);
      if (print) {
        int nPass=nParams - totalNFailures;
        log.info("String_Node_Str" + nParams + "String_Node_Str"+ nPass+ "String_Node_Str"+ totalNFailures+ "String_Node_Str"+ maxError);
      }
    }
  }
  return totalNFailures == 0;
}