code: public Pair<Gradient,INDArray> calculateGradients(@NonNull INDArray features, @NonNull INDArray label,
                                                        INDArray fMask, INDArray labelMask) {
          try{
              return calculateGradientsHelper(features, label, fMask, labelMask);
          } catch (OutOfMemoryError e){
              CrashReportingUtil.writeMemoryCrashDump(this, e);
              throw e;
          }
      }
docs: Calculate parameter gradients and input activation gradients given the input and labels, and optionally mask arrays
  
  @param features  Features for gradient calculation
  @param label     Labels for gradient
  @param fMask     Features mask array (may be null)
  @param labelMask Label mask array (may be null)
  @return A pair of gradient arrays: parameter gradients (in Gradient object) and input activation gradients