nus-yam/ex-repair huggingface dataset:
Program: 3174
Project: 3174
Buggy source:
/** 
 * Leaky relu with an alpha of 0.01
 * @param value the value to transform
 * @return
 */
X leakyReluDerivative(X value);

Fixed version (ground truth):
/** 
 * Leaky relu with an alpha of 0.01
 * @param value the value to transform
 * @param wrt
 * @return
 */
X leakyReluDerivative(X value,X wrt);
Program: 3175
Project: 3175
Buggy source:
X seluDerivative(X value);

Fixed version (ground truth):
X seluDerivative(X value,X wrt);
Program: 3176
Project: 3176
Buggy source:
@Override public ArrayField tanhDerivative(ArrayField x){
  return x.tanhDerivative();
}

Fixed version (ground truth):
@Override public ArrayField tanhDerivative(ArrayField x,ArrayField wrt){
  return x.tanhDerivative(wrt);
}
Program: 3177
Project: 3177
Buggy source:
/** 
 * Leaky relu with an alpha of 0.01
 * @param value the value to transform
 * @return
 */
@Override public ArrayField leakyReluDerivative(ArrayField value){
}

Fixed version (ground truth):
/** 
 * Leaky relu with an alpha of 0.01
 * @param value the value to transform
 * @param wrt
 * @return
 */
@Override public ArrayField leakyReluDerivative(ArrayField value,ArrayField wrt){
  return value.leakyReluDerivative(wrt,0.001);
}
Program: 3178
Project: 3178
Buggy source:
@Override public ArrayField seluDerivative(ArrayField value){
  return value.seluDerivative();
}

Fixed version (ground truth):
@Override public ArrayField seluDerivative(ArrayField value,ArrayField wrt){
  return value.seluDerivative(wrt);
}
Program: 3179
Project: 3179
Buggy source:
@Override public ArrayField tanhDerivative(){
  return addTransformOp(new TanhDerivative().name());
}

Fixed version (ground truth):
@Override public ArrayField tanhDerivative(ArrayField wrt){
  return addTransformOp(new TanhDerivative().name());
}
Program: 3180
Project: 3180
Buggy source:
@Override public ArrayField seluDerivative(){
  return addTransformOp(new SELUDerivative().name());
}

Fixed version (ground truth):
@Override public ArrayField seluDerivative(ArrayField wrt){
  return addTransformOp(new SELUDerivative().name());
}
Program: 3181
Project: 3181
Buggy source:
X seluDerivative();

Fixed version (ground truth):
X seluDerivative(X wrt);
Program: 3182
Project: 3182
Buggy source:
X tanhDerivative();

Fixed version (ground truth):
X tanhDerivative(X wrt);
Program: 3183
Project: 3183
Buggy source:
public AbstractBinaryFunction(SameDiff sameDiff){
  this.sameDiff=sameDiff;
}

Fixed version (ground truth):
public AbstractBinaryFunction(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v1,DifferentialFunction<ArrayField> i_v2,OpState.OpType opType,Object[] extraArgs){
  super(sameDiff,extraArgs);
  if (i_v1 != null && i_v2 != null) {
    m_x1=i_v1;
    m_x2=i_v2;
    validateDifferentialFunctionsameDiff(i_v1);
    validateDifferentialFunctionsameDiff(i_v2);
    this.sameDiff=sameDiff;
    addEdges(sameDiff,i_v1,i_v2,functionName(),opType,i_v1.getResultShape(),null);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 3184
Project: 3184
Buggy source:
@Override public DifferentialFunction<X> tanhDerivative(){
  return null;
}

Fixed version (ground truth):
@Override public DifferentialFunction<X> tanhDerivative(DifferentialFunction<X> wrt){
  return null;
}
Program: 3185
Project: 3185
Buggy source:
@Override public DifferentialFunction<X> seluDerivative(){
  return null;
}

Fixed version (ground truth):
@Override public DifferentialFunction<X> seluDerivative(DifferentialFunction<X> wrt){
  return null;
}
Program: 3186
Project: 3186
Buggy source:
@Override public DifferentialFunction<ArrayField> leakyReluDerivative(DifferentialFunction<ArrayField> iX,double cutoff){
  return new LeakyReluDerivative(sameDiff,iX,cutoff);
}

Fixed version (ground truth):
@Override public DifferentialFunction<ArrayField> leakyReluDerivative(DifferentialFunction<ArrayField> iX,DifferentialFunction<ArrayField> iY,double cutoff){
  return new LeakyReluDerivative(sameDiff,iX,iY,cutoff);
}
Program: 3187
Project: 3187
Buggy source:
DifferentialFunction<X> leakyReluDerivative(DifferentialFunction<X> iX,double cutoff);

Fixed version (ground truth):
DifferentialFunction<X> leakyReluDerivative(DifferentialFunction<X> iX,DifferentialFunction<X> iY,double cutoff);
Program: 3188
Project: 3188
Buggy source:
public EluDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,Object[] extraArgs){
  super(sameDiff,i_v,extraArgs);
}

Fixed version (ground truth):
public EluDerivative(SameDiff sameDiff){
  super(sameDiff);
}
Program: 3189
Project: 3189
Buggy source:
@Override public ArrayField doGetValue(){
}

Fixed version (ground truth):
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().eluDerivative(larg().getValue(true),rarg().getValue(true));
}
Program: 3190
Project: 3190
Buggy source:
@Override public ArrayField doGetValue(){
}

Fixed version (ground truth):
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().hardTanhDerivative(larg().getValue(true),rarg().getValue(true));
}
Program: 3191
Project: 3191
Buggy source:
public HardTanhDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,Object[] extraArgs){
  super(sameDiff,i_v,extraArgs);
}

Fixed version (ground truth):
public HardTanhDerivative(SameDiff sameDiff){
  super(sameDiff);
}
Program: 3192
Project: 3192
Buggy source:
@Override public ArrayField doGetValue(){
}

Fixed version (ground truth):
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().leakyReluDerivative(larg().getValue(true),rarg().getValue(true),cutoff);
}
Program: 3193
Project: 3193
Buggy source:
public LeakyReluDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,double cutoff){
  super(sameDiff,i_v,new Object[]{cutoff});
  this.cutoff=cutoff;
}

Fixed version (ground truth):
public LeakyReluDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,DifferentialFunction<ArrayField> i_v2,double cutoff){
  super(sameDiff,i_v,i_v2,OpState.OpType.GRADIENT,new Object[]{cutoff});
  this.cutoff=cutoff;
}
Program: 3194
Project: 3194
Buggy source:
public SELUDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,Object[] extraArgs){
  super(sameDiff,i_v,extraArgs);
}

Fixed version (ground truth):
public SELUDerivative(SameDiff sameDiff){
  super(sameDiff);
}
Program: 3195
Project: 3195
Buggy source:
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().seluDerivative(arg().getValue(true));
}

Fixed version (ground truth):
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().seluDerivative(larg().getValue(true),rarg().getValue(true));
}
Program: 3196
Project: 3196
Buggy source:
@Override public ArrayField doGetValue(){
}

Fixed version (ground truth):
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().softsignDeriviative(larg().getValue(true),rarg().getValue(true));
}
Program: 3197
Project: 3197
Buggy source:
public SoftSignDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,Object[] extraArgs){
  super(sameDiff,i_v,extraArgs);
}

Fixed version (ground truth):
public SoftSignDerivative(SameDiff sameDiff){
  super(sameDiff);
}
Program: 3198
Project: 3198
Buggy source:
public TanhDerivative(SameDiff sameDiff,DifferentialFunction<ArrayField> i_v,Object[] extraArgs){
  super(sameDiff,i_v,extraArgs);
}

Fixed version (ground truth):
public TanhDerivative(SameDiff sameDiff){
  super(sameDiff);
}
Program: 3199
Project: 3199
Buggy source:
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().tanhDerivative(arg().getValue(true));
}

Fixed version (ground truth):
@Override public ArrayField doGetValue(){
  return sameDiff.getArrayFactory().tanhDerivative(larg().getValue(true),rarg().getValue(true));
}
Program: 3200
Project: 3200
Buggy source:
@Override public DifferentialFunction<ArrayField> diff(DifferentialFunction<ArrayField> i_v){
  return sameDiff.getFunctionFactory().leakyReluDerivative(arg(),cutoff).mul(arg().diff(i_v));
}

Fixed version (ground truth):
@Override public DifferentialFunction<ArrayField> diff(DifferentialFunction<ArrayField> i_v){
  return sameDiff.getFunctionFactory().leakyReluDerivative(arg(),i_v,cutoff);
}
Program: 3201
Project: 3201
Buggy source:
@Override public DifferentialFunction<ArrayField> diff(DifferentialFunction<ArrayField> i_v){
  return softsignDerivative().mul(arg().diff(i_v));
}

Fixed version (ground truth):
@Override public DifferentialFunction<ArrayField> diff(DifferentialFunction<ArrayField> i_v){
  return softsignDerivative(i_v);
}
Program: 3202
Project: 3202
Buggy source:
/** 
 * Compute the sparse offsets of the view we are getting, for each dimension according to the original ndarray
 * @param offset the offset of the view
 * @return an int array containing the sparse offsets
 */
private int[] createSparseOffsets(int offset,int[] toremove){
  int underlyingRank=(int)sparseOffsets.length();
  int[] newOffsets=new int[rank()];
  List<Integer> shapeList=Ints.asList(shape());
  int penultimate=rank() - 1;
  for (int i=0; i < penultimate; i++) {
    int prod=ArrayUtil.prod(shapeList.subList(i,penultimate));
    newOffsets[i]=offset / prod;
    offset=offset - newOffsets[i] * prod;
  }
  newOffsets[rank() - 1]=offset % underlyingShape.getInt(rank() - 1);
  int[] finalOffsets=new int[underlyingRank];
  int dimNotFixed=0;
  for (int dim=0; dim < underlyingRank; dim++) {
    if (fixed.getInt(dim) == 1) {
      finalOffsets[dim]=sparseOffsets.getInt(dim);
    }
 else {
      finalOffsets[dim]=newOffsets[dimNotFixed] + sparseOffsets.getInt(dim);
      dimNotFixed++;
    }
  }
  return finalOffsets;
}

Fixed version (ground truth):
/** 
 * Compute the sparse offsets of the view we are getting, for each dimension according to the original ndarray
 * @param offset the offset of the view
 * @return an int array containing the sparse offsets
 */
private int[] createSparseOffsets(int offset){
  int underlyingRank=(int)sparseOffsets.length();
  int[] newOffsets=new int[rank()];
  List<Integer> shapeList=Ints.asList(shape());
  int penultimate=rank() - 1;
  for (int i=0; i < penultimate; i++) {
    int prod=ArrayUtil.prod(shapeList.subList(i + 1,rank()));
    newOffsets[i]=offset / prod;
    offset=offset - newOffsets[i] * prod;
  }
  newOffsets[rank() - 1]=offset % shape()[rank() - 1];
  int[] finalOffsets=new int[underlyingRank];
  int dimNotFixed=0;
  for (int dim=0; dim < underlyingRank; dim++) {
    if (fixed.getInt(dim) == 1) {
      finalOffsets[dim]=sparseOffsets.getInt(dim);
    }
 else {
      finalOffsets[dim]=newOffsets[dimNotFixed] + sparseOffsets.getInt(dim);
      dimNotFixed++;
    }
  }
  return finalOffsets;
}
Program: 3203
Project: 3203
Buggy source:
public void setFixed(int[] arr){
  if (isScalar() || isRowVector() || isColumnVector()) {
    this.fixed=Nd4j.createBuffer(new int[]{0,0});
  }
 else {
    this.fixed=Nd4j.createBuffer(arr);
  }
}

Fixed version (ground truth):
public void setFixed(int[] arr){
  if (!isView() && (isScalar() || isRowVector() || isColumnVector())) {
    this.fixed=Nd4j.createBuffer(new int[]{0,0});
  }
 else {
    this.fixed=Nd4j.createBuffer(arr);
  }
}
Program: 3204
Project: 3204
Buggy source:
public BaseSparseNDArrayCOO(DataBuffer values,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,int[] underlyingShape,char ordering){
  this.values=Nd4j.createBuffer(values,0,values.length());
  this.indices=indices;
  this.sparseOffsets=Nd4j.createBuffer(sparseOffsets);
  setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape,ordering));
  this.underlyingShape=Nd4j.createBuffer(underlyingShape);
  init(shape);
  setFixed(fixed);
  this.length=countNNZ();
}

Fixed version (ground truth):
public BaseSparseNDArrayCOO(DataBuffer values,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,char ordering){
  this.values=Nd4j.createBuffer(values,0,values.length());
  this.indices=indices;
  this.sparseOffsets=Nd4j.createBuffer(sparseOffsets);
  setShapeInformation(Nd4j.getShapeInfoProvider().createShapeInformation(shape,ordering));
  init(shape);
  setFixed(fixed);
  this.length=countNNZ();
}
Program: 3205
Project: 3205
Buggy source:
public DataBuffer getIndices(){
  if (isScalar()) {
    return Nd4j.createBuffer(new int[]{0,0});
  }
  List<Integer> ind=new ArrayList<>();
  for (int i=0; i < values.length(); i++) {
    boolean isIn=true;
    int idxNotFixed=0;
    int[] idx=getIndicesOf(i).asInt();
    for (int dim=0; dim < idx.length; dim++) {
      if (fixed.getInt(dim) == 1) {
        if (sparseOffsets.getInt(dim) != idx[dim]) {
          isIn=false;
          break;
        }
      }
 else {
        int lowerBound=sparseOffsets.getInt(dim);
        int upperBound=sparseOffsets.getInt(dim) + shape()[idxNotFixed];
        if (!(idx[dim] >= lowerBound && idx[dim] < upperBound)) {
          isIn=false;
          break;
        }
        idxNotFixed++;
      }
    }
    if (isIn) {
      for (int dim=0; dim < idx.length; dim++) {
        if (fixed.getInt(dim) == 0) {
          ind.add(idx[dim] - sparseOffsets.getInt(dim));
        }
      }
    }
  }
  return Nd4j.createBuffer(Ints.toArray(ind));
}

Fixed version (ground truth):
public DataBuffer getIndices(){
  if (isScalar()) {
    return Nd4j.createBuffer(new int[]{0,0});
  }
  List<Integer> ind=new ArrayList<>();
  for (int i=0; i < values.length(); i++) {
    boolean isIn=true;
    int idxNotFixed=0;
    int[] idx=getIndicesOf(i).asInt();
    for (int dim=0; dim < idx.length; dim++) {
      if (fixed.getInt(dim) == 1) {
        if (sparseOffsets.getInt(dim) != idx[dim]) {
          isIn=false;
          break;
        }
      }
 else {
        int lowerBound=sparseOffsets.getInt(dim);
        int upperBound=sparseOffsets.getInt(dim) + shape()[idxNotFixed];
        if (!(idx[dim] >= lowerBound && idx[dim] < upperBound)) {
          isIn=false;
          break;
        }
        idxNotFixed++;
      }
    }
    if (isIn) {
      int notFixedDim=0;
      for (int dim=0; dim < idx.length; dim++) {
        if (fixed.getInt(dim) == 0) {
          if (shape()[notFixedDim] == 1) {
            ind.add(0);
            notFixedDim++;
          }
 else {
            ind.add(idx[dim] - sparseOffsets.getInt(dim));
          }
        }
      }
    }
  }
  return Nd4j.createBuffer(Ints.toArray(ind));
}
Program: 3206
Project: 3206
Buggy source:
private INDArray create(DataBuffer values,DataBuffer indices,int[] newShape,int[] sparseOffsets,int[] fixed,char newOrder){
  return Nd4j.createSparseCOO(values,indices,sparseOffsets,fixed,newShape,shape(),newOrder);
}

Fixed version (ground truth):
private INDArray create(DataBuffer values,DataBuffer indices,int[] newShape,int[] sparseOffsets,int[] fixed,char newOrder){
  return Nd4j.createSparseCOO(values,indices,sparseOffsets,fixed,newShape,newOrder);
}
Program: 3207
Project: 3207
Buggy source:
public int underlyingRank(){
  return (int)underlyingShape.length();
}

Fixed version (ground truth):
public int underlyingRank(){
  return (int)sparseOffsets.length();
}
Program: 3208
Project: 3208
Buggy source:
INDArray createSparseCOO(DataBuffer data,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,int[] underlyingShape,char ordering);

Fixed version (ground truth):
INDArray createSparseCOO(DataBuffer data,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,char ordering);
Program: 3209
Project: 3209
Buggy source:
/** 
 * @param values a DataBuffer with the sparse non-null values
 * @param indices a DataBuffer with the indexes of the values
 * @param sparseOffsets the sparse
 * @param fixed
 * @param shape
 * @return ordering
 * @return a INDArray
 */
public static INDArray createSparseCOO(DataBuffer values,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,int[] underlyingShape,char ordering){
  INDArray matrix=SPARSE_INSTANCE.createSparseCOO(values,indices,sparseOffsets,fixed,shape,underlyingShape,ordering);
  return matrix;
}

Fixed version (ground truth):
/** 
 * @param values a DataBuffer with the sparse non-null values
 * @param indices a DataBuffer with the indexes of the values
 * @param sparseOffsets the sparse
 * @param fixed
 * @param shape
 * @return ordering
 * @return a INDArray
 */
public static INDArray createSparseCOO(DataBuffer values,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,char ordering){
  INDArray matrix=SPARSE_INSTANCE.createSparseCOO(values,indices,sparseOffsets,fixed,shape,ordering);
  return matrix;
}
Program: 3210
Project: 3210
Buggy source:
@Override public INDArray createSparseCOO(DataBuffer data,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,int[] underlyingShape,char ordering){
  throw new UnsupportedOperationException();
}

Fixed version (ground truth):
@Override public INDArray createSparseCOO(DataBuffer data,DataBuffer indices,int[] sparseOffsets,int[] fixed,int[] shape,char ordering){
  throw new UnsupportedOperationException();
}
Program: 3211
Project: 3211
Buggy source:
@Override public INDArray createSparseCOO(DataBuffer data,DataBuffer indices,int[] sparseOffset,int[] fixed,int[] shape,int[] underlyingShape,char ordering){
  return new SparseNDArrayCOO(data,indices,sparseOffset,fixed,shape,underlyingShape,ordering);
}

Fixed version (ground truth):
@Override public INDArray createSparseCOO(DataBuffer data,DataBuffer indices,int[] sparseOffset,int[] fixed,int[] shape,char ordering){
  return new SparseNDArrayCOO(data,indices,sparseOffset,fixed,shape,ordering);
}
Program: 3212
Project: 3212
Buggy source:
public SparseNDArrayCOO(DataBuffer values,DataBuffer indices,int[] sparseOffset,int[] fixed,int[] shape,int[] underlyingShape,char ordering){
  super(values,indices,sparseOffset,fixed,shape,underlyingShape,ordering);
}

Fixed version (ground truth):
public SparseNDArrayCOO(DataBuffer values,DataBuffer indices,int[] sparseOffset,int[] fixed,int[] shape,char ordering){
  super(values,indices,sparseOffset,fixed,shape,ordering);
}
Program: 3213
Project: 3213
Buggy source:
@Test public void shouldTakeViewOfView2(){
  int[] shape=new int[]{4,2,3};
  double[] values=new double[]{1,2,3,4,5,6,7,8,9};
  int[][] indices=new int[][]{{0,0,2},{0,1,1},{1,0,0},{1,0,1},{1,1,2},{2,0,1},{2,1,2},{3,0,1},{3,1,0}};
  INDArray array=Nd4j.createSparseCOO(values,indices,shape);
  BaseSparseNDArrayCOO baseView=(BaseSparseNDArrayCOO)array.get(NDArrayIndex.interval(1,4),NDArrayIndex.point(1),NDArrayIndex.all());
  BaseSparseNDArrayCOO view=(BaseSparseNDArrayCOO)baseView.get(NDArrayIndex.all(),NDArrayIndex.point(2));
  assertEquals(2,view.nnz());
  assertArrayEquals(new int[]{3,1},view.shape());
  assertArrayEquals(new int[]{0,0,0,1},view.getIndices().asInt());
  assertArrayEquals(new double[]{5,7},view.getValues().asDouble(),1e-1);
}

Fixed version (ground truth):
@Test public void shouldTakeViewOfView2(){
  int[] shape=new int[]{4,2,3};
  double[] values=new double[]{1,2,3,4,5,6,7,8,9};
  int[][] indices=new int[][]{{0,0,2},{0,1,1},{1,0,0},{1,0,1},{1,1,2},{2,0,1},{2,1,2},{3,0,1},{3,1,0}};
  INDArray array=Nd4j.createSparseCOO(values,indices,shape);
  BaseSparseNDArrayCOO baseView=(BaseSparseNDArrayCOO)array.get(NDArrayIndex.interval(1,4),NDArrayIndex.point(1),NDArrayIndex.all());
  BaseSparseNDArrayCOO view=(BaseSparseNDArrayCOO)baseView.get(NDArrayIndex.all(),NDArrayIndex.point(2));
  assertEquals(2,view.nnz());
  assertArrayEquals(new int[]{3,1},view.shape());
  assertArrayEquals(new int[]{0,0,1,0},view.getIndices().asInt());
  assertArrayEquals(new double[]{5,7},view.getValues().asDouble(),1e-1);
}
Program: 3216
Project: 3216
Buggy source:
@Override public void run(){
  while (true) {
    try {
      Nd4jWorkspace.GarbageWorkspaceReference reference=(Nd4jWorkspace.GarbageWorkspaceReference)queue.remove();
      if (reference != null) {
        PointersPair pair=reference.getPointersPair();
        if (pair != null) {
          if (pair.getDevicePointer() != null) {
            log.info("String_Node_Str");
            Nd4j.getMemoryManager().release(pair.getDevicePointer(),MemoryKind.DEVICE);
          }
          if (pair.getHostPointer() != null) {
            referenceMap.remove(reference.getId() + "String_Node_Str" + reference.getThreadId());
            Nd4j.getMemoryManager().release(pair.getHostPointer(),MemoryKind.HOST);
          }
        }
        for (        PointersPair pair2 : reference.getExternalPointers()) {
          if (pair2 != null) {
            if (pair2.getHostPointer() != null)             Nd4j.getMemoryManager().release(pair2.getHostPointer(),MemoryKind.HOST);
            if (pair2.getDevicePointer() != null)             Nd4j.getMemoryManager().release(pair2.getDevicePointer(),MemoryKind.DEVICE);
          }
        }
        while ((pair=reference.getPinnedPointers().poll()) != null) {
          if (pair.getHostPointer() != null)           Nd4j.getMemoryManager().release(pair.getHostPointer(),MemoryKind.HOST);
          if (pair.getDevicePointer() != null)           Nd4j.getMemoryManager().release(pair.getDevicePointer(),MemoryKind.DEVICE);
        }
      }
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    try {
      Nd4jWorkspace.GarbageWorkspaceReference reference=(Nd4jWorkspace.GarbageWorkspaceReference)queue.remove();
      if (reference != null) {
        PointersPair pair=reference.getPointersPair();
        if (pair != null) {
          if (pair.getDevicePointer() != null) {
            Nd4j.getMemoryManager().release(pair.getDevicePointer(),MemoryKind.DEVICE);
          }
          if (pair.getHostPointer() != null) {
            referenceMap.remove(reference.getId() + "String_Node_Str" + reference.getThreadId());
            Nd4j.getMemoryManager().release(pair.getHostPointer(),MemoryKind.HOST);
          }
        }
        for (        PointersPair pair2 : reference.getExternalPointers()) {
          if (pair2 != null) {
            if (pair2.getHostPointer() != null)             Nd4j.getMemoryManager().release(pair2.getHostPointer(),MemoryKind.HOST);
            if (pair2.getDevicePointer() != null)             Nd4j.getMemoryManager().release(pair2.getDevicePointer(),MemoryKind.DEVICE);
          }
        }
        while ((pair=reference.getPinnedPointers().poll()) != null) {
          if (pair.getHostPointer() != null)           Nd4j.getMemoryManager().release(pair.getHostPointer(),MemoryKind.HOST);
          if (pair.getDevicePointer() != null)           Nd4j.getMemoryManager().release(pair.getDevicePointer(),MemoryKind.DEVICE);
        }
      }
    }
 catch (    Exception e) {
    }
  }
}
Program: 3217
Project: 3217
Buggy source:
@Override public void setStateViewArray(INDArray viewArray,int[] gradientShape,char gradientOrder,boolean initialize){
  if (!viewArray.isRowVector())   throw new IllegalArgumentException("String_Node_Str");
  if (initialize)   viewArray.assign(epsilon);
  this.historicalGradient=viewArray;
  this.historicalGradient=Shape.newShapeNoCopy(this.historicalGradient,gradientShape,gradientOrder == 'f');
  if (historicalGradient == null)   throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
@Override public void setStateViewArray(INDArray viewArray,int[] gradientShape,char gradientOrder,boolean initialize){
  if (!viewArray.isRowVector())   throw new IllegalArgumentException("String_Node_Str");
  if (initialize)   viewArray.assign(epsilon);
  this.historicalGradient=viewArray;
  this.historicalGradient=Shape.newShapeNoCopy(this.historicalGradient,gradientShape,gradientOrder == 'f');
  if (historicalGradient == null)   throw new IllegalStateException("String_Node_Str");
  this.gradientReshapeOrder=gradientOrder;
}
Program: 3218
Project: 3218
Buggy source:
@Override public IComplexNumber op(IComplexNumber origin){
  if (origin.absoluteValue().doubleValue() > complexNumber.absoluteValue().doubleValue())   return origin;
  return complexNumber;
}

Fixed version (ground truth):
@Override public IComplexNumber op(IComplexNumber origin){
  if (origin.absoluteValue().doubleValue() < complexNumber.absoluteValue().doubleValue())   return origin;
  return complexNumber;
}
Program: 3222
Project: 3222
Buggy source:
@Before public void randomData(){
  batchSize=13;
  batchCount=20;
  lastBatch=batchSize / 2;
  INDArray origFeatures=Nd4j.rand(batchCount * batchSize + lastBatch,10);
  INDArray origLabels=Nd4j.rand(batchCount * batchSize + lastBatch,3);
  data=new DataSet(origFeatures,origLabels);
  stdScaler=new NormalizerStandardize();
  minMaxScaler=new NormalizerMinMaxScaler();
}

Fixed version (ground truth):
@Before public void randomData(){
  Nd4j.getRandom().setSeed(12345);
  batchSize=13;
  batchCount=20;
  lastBatch=batchSize / 2;
  INDArray origFeatures=Nd4j.rand(batchCount * batchSize + lastBatch,10);
  INDArray origLabels=Nd4j.rand(batchCount * batchSize + lastBatch,3);
  data=new DataSet(origFeatures,origLabels);
  stdScaler=new NormalizerStandardize();
  minMaxScaler=new NormalizerMinMaxScaler();
}
Program: 3223
Project: 3223
Buggy source:
@Test public void testPreProcessors(){
  System.out.println("String_Node_Str");
  assertTrue(testItervsDataset(stdScaler) < thresholdPerc);
  System.out.println("String_Node_Str");
  assertTrue(testItervsDataset(minMaxScaler) < thresholdPerc);
}

Fixed version (ground truth):
@Test public void testPreProcessors(){
  System.out.println("String_Node_Str");
  double d1=testItervsDataset(stdScaler);
  assertTrue(d1 + "String_Node_Str" + thresholdPerc,d1 < thresholdPerc);
  System.out.println("String_Node_Str");
  double d2=testItervsDataset(minMaxScaler);
  assertTrue(d2 + "String_Node_Str" + thresholdPerc,d2 < thresholdPerc);
}
Program: 3225
Project: 3225
Buggy source:
/** 
 * Undo (revert) the normalization applied by this normalizer to a specific features array. If labels normalization is disabled (i.e.,   {@link #isFitLabel()} == false) then this is a no-op.Can also be used to undo normalization for network output arrays, in the case of regression.
 * @param features features arrays to revert the normalization on
 * @param input the index of the array to revert
 */
public void revertFeatures(@NonNull INDArray features,int input){
  strategy.revert(features,getFeatureStats(input));
}

Fixed version (ground truth):
/** 
 * Undo (revert) the normalization applied by this normalizer to a specific features array. If labels normalization is disabled (i.e.,   {@link #isFitLabel()} == false) then this is a no-op.Can also be used to undo normalization for network output arrays, in the case of regression.
 * @param features features arrays to revert the normalization on
 * @param input    the index of the array to revert
 */
public void revertFeatures(@NonNull INDArray features,int input){
  strategy.revert(features,getFeatureStats(input));
}
Program: 3226
Project: 3226
Buggy source:
private void fitPartial(MultiDataSet dataSet,List<S.Builder> featureStatsBuilders,List<S.Builder> labelStatsBuilders){
  int numInputs=dataSet.getFeatures().length;
  int numOutputs=dataSet.getLabels().length;
  ensureStatsBuilders(featureStatsBuilders,numInputs);
  ensureStatsBuilders(labelStatsBuilders,numOutputs);
  for (int i=0; i < numInputs; i++) {
    featureStatsBuilders.get(i).add(dataSet.getFeatures(i),dataSet.getFeaturesMaskArray(i));
  }
  if (isFitLabel()) {
    for (int i=0; i < numOutputs; i++) {
      labelStatsBuilders.get(i).add(dataSet.getLabels(i),dataSet.getLabelsMaskArray(i));
    }
  }
}

Fixed version (ground truth):
private void fitPartial(MultiDataSet dataSet,List<S.Builder> featureStatsBuilders,List<S.Builder> labelStatsBuilders){
  int numInputs=dataSet.numFeatureArrays();
  int numOutputs=dataSet.numLabelsArrays();
  ensureStatsBuilders(featureStatsBuilders,numInputs);
  ensureStatsBuilders(labelStatsBuilders,numOutputs);
  for (int i=0; i < numInputs; i++) {
    featureStatsBuilders.get(i).add(dataSet.getFeatures(i),dataSet.getFeaturesMaskArray(i));
  }
  if (isFitLabel()) {
    for (int i=0; i < numOutputs; i++) {
      labelStatsBuilders.get(i).add(dataSet.getLabels(i),dataSet.getLabelsMaskArray(i));
    }
  }
}
Program: 3227
Project: 3227
Buggy source:
/** 
 * Undo (revert) the normalization applied by this normalizer to a specific features array. If labels normalization is disabled (i.e.,   {@link #isFitLabels()} == false) then this is a no-op.Can also be used to undo normalization for network output arrays, in the case of regression.
 * @param features features arrays to revert the normalization on
 * @param input the index of the array to revert
 */
public void revertFeatures(@NonNull INDArray features,int input){
  strategy.revert(features,getFeatureStats(input));
}

Fixed version (ground truth):
/** 
 * Undo (revert) the normalization applied by this normalizer to a specific features array. If labels normalization is disabled (i.e.,   {@link #isFitLabel()} == false) then this is a no-op.Can also be used to undo normalization for network output arrays, in the case of regression.
 * @param features features arrays to revert the normalization on
 * @param input the index of the array to revert
 */
public void revertFeatures(@NonNull INDArray features,int input){
  strategy.revert(features,getFeatureStats(input));
}
Program: 3228
Project: 3228
Buggy source:
/** 
 * Pre process a MultiDataSet
 * @param toPreProcess the data set to pre process
 */
@Override public void preProcess(@NonNull MultiDataSet toPreProcess){
  int numFeatures=toPreProcess.getFeatures().length;
  int numLabels=toPreProcess.getLabels().length;
  for (int i=0; i < numFeatures; i++) {
    strategy.preProcess(toPreProcess.getFeatures(i),getFeatureStats(i));
  }
  if (isFitLabel()) {
    for (int i=0; i < numLabels; i++) {
      strategy.preProcess(toPreProcess.getLabels(i),getLabelStats(i));
    }
  }
}

Fixed version (ground truth):
/** 
 * Pre process a MultiDataSet
 * @param toPreProcess the data set to pre process
 */
@Override public void preProcess(@NonNull MultiDataSet toPreProcess){
  int numFeatures=toPreProcess.numFeatureArrays();
  int numLabels=toPreProcess.numLabelsArrays();
  for (int i=0; i < numFeatures; i++) {
    strategy.preProcess(toPreProcess.getFeatures(i),getFeatureStats(i));
  }
  if (isFitLabel()) {
    for (int i=0; i < numLabels; i++) {
      strategy.preProcess(toPreProcess.getLabels(i),getLabelStats(i));
    }
  }
}
Program: 3229
Project: 3229
Buggy source:
/** 
 * Undo (revert) the normalization applied by this normalizer to a specific labels array. If labels normalization is disabled (i.e.,   {@link #isFitLabels()} == false) then this is a no-op.Can also be used to undo normalization for network output arrays, in the case of regression.
 * @param labels Labels arrays to revert the normalization on
 * @param output the index of the array to revert
 */
public void revertLabels(@NonNull INDArray labels,int output){
  if (isFitLabel()) {
    strategy.revert(labels,getLabelStats(output));
  }
}

Fixed version (ground truth):
/** 
 * Undo (revert) the normalization applied by this normalizer to a specific labels array. If labels normalization is disabled (i.e.,   {@link #isFitLabel()} == false) then this is a no-op.Can also be used to undo normalization for network output arrays, in the case of regression.
 * @param labels Labels arrays to revert the normalization on
 * @param output the index of the array to revert
 */
public void revertLabels(@NonNull INDArray labels,int output){
  if (isFitLabel()) {
    strategy.revert(labels,getLabelStats(output));
  }
}
Program: 3230
Project: 3230
Buggy source:
/** 
 * Denormalize a data array
 * @param array the data to denormalize
 * @param stats statistics of the data population
 */
@Override public void revert(INDArray array,MinMaxStats stats){
  array.subi(minRange);
  array.divi(maxRange - minRange);
  if (array.rank() <= 2) {
    array.muliRowVector(stats.getRange());
    array.addiRowVector(stats.getLower());
  }
 else {
    Nd4j.getExecutioner().execAndReturn(new BroadcastMulOp(array,stats.getUpper(),array,1));
    Nd4j.getExecutioner().execAndReturn(new BroadcastAddOp(array,stats.getLower(),array,1));
  }
}

Fixed version (ground truth):
/** 
 * Denormalize a data array
 * @param array the data to denormalize
 * @param stats statistics of the data population
 */
@Override public void revert(INDArray array,MinMaxStats stats){
  array.subi(minRange);
  array.divi(maxRange - minRange);
  if (array.rank() <= 2) {
    array.muliRowVector(stats.getRange());
    array.addiRowVector(stats.getLower());
  }
 else {
    Nd4j.getExecutioner().execAndReturn(new BroadcastMulOp(array,stats.getRange(),array,1));
    Nd4j.getExecutioner().execAndReturn(new BroadcastAddOp(array,stats.getLower(),array,1));
  }
}
Program: 3231
Project: 3231
Buggy source:
/** 
 * Normalize a data array
 * @param array the data to normalize
 * @param stats statistics of the data population
 */
@Override public void preProcess(INDArray array,MinMaxStats stats){
  if (array.rank() <= 2) {
    array.subiRowVector(stats.getLower());
    array.diviRowVector(stats.getRange());
  }
 else {
    Nd4j.getExecutioner().execAndReturn(new BroadcastSubOp(array,stats.getLower(),array,1));
    Nd4j.getExecutioner().execAndReturn(new BroadcastDivOp(array,stats.getUpper(),array,1));
  }
  array.muli(maxRange - minRange);
  array.addi(minRange);
}

Fixed version (ground truth):
/** 
 * Normalize a data array
 * @param array the data to normalize
 * @param stats statistics of the data population
 */
@Override public void preProcess(INDArray array,MinMaxStats stats){
  if (array.rank() <= 2) {
    array.subiRowVector(stats.getLower());
    array.diviRowVector(stats.getRange());
  }
 else {
    Nd4j.getExecutioner().execAndReturn(new BroadcastSubOp(array,stats.getLower(),array,1));
    Nd4j.getExecutioner().execAndReturn(new BroadcastDivOp(array,stats.getRange(),array,1));
  }
  array.muli(maxRange - minRange);
  array.addi(minRange);
}
Program: 3232
Project: 3232
Buggy source:
/** 
 * Add rows of data to the statistics
 * @param data the matrix containing multiple rows of data to include
 * @param mask (optionally) the mask of the data, useful for e.g. time series
 */
public Builder add(@NonNull INDArray data,INDArray mask){
  data=DataSetUtil.tailor2d(data,mask);
  int count=data.size(0);
  if (count == 0) {
    return this;
  }
  INDArray mean=data.mean(0);
  INDArray variance=data.var(false,0);
  if (runningMean == null) {
    runningMean=mean;
    runningVariance=variance;
    runningCount=count;
  }
 else {
    INDArray deltaSquared=Transforms.pow(mean.subRowVector(runningMean),2);
    INDArray mB=variance.muli(count);
    runningVariance.muli(runningCount).addiRowVector(mB).addiRowVector(deltaSquared.muli((float)(runningCount * count) / (runningCount + count))).divi(runningCount + count);
    runningCount+=count;
    INDArray xMinusMean=data.subRowVector(runningMean);
    runningMean.addi(xMinusMean.sum(0).divi(runningCount));
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Add rows of data to the statistics
 * @param data the matrix containing multiple rows of data to include
 * @param mask (optionally) the mask of the data, useful for e.g. time series
 */
public Builder add(@NonNull INDArray data,INDArray mask){
  data=DataSetUtil.tailor2d(data,mask);
  if (data == null) {
    return this;
  }
  INDArray mean=data.mean(0);
  INDArray variance=data.var(false,0);
  int count=data.size(0);
  if (runningMean == null) {
    runningMean=mean;
    runningVariance=variance;
    runningCount=count;
  }
 else {
    INDArray deltaSquared=Transforms.pow(mean.subRowVector(runningMean),2);
    INDArray mB=variance.muli(count);
    runningVariance.muli(runningCount).addiRowVector(mB).addiRowVector(deltaSquared.muli((float)(runningCount * count) / (runningCount + count))).divi(runningCount + count);
    runningCount+=count;
    INDArray xMinusMean=data.subRowVector(runningMean);
    runningMean.addi(xMinusMean.sum(0).divi(runningCount));
  }
  return this;
}
Program: 3233
Project: 3233
Buggy source:
/** 
 * Create a DistributionStats object from the data ingested so far. Can be used multiple times when updating online.
 */
public DistributionStats build(){
  return new DistributionStats(runningMean.dup(),Transforms.sqrt(runningVariance,true));
}

Fixed version (ground truth):
/** 
 * Create a DistributionStats object from the data ingested so far. Can be used multiple times when updating online.
 */
public DistributionStats build(){
  if (runningMean == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return new DistributionStats(runningMean.dup(),Transforms.sqrt(runningVariance,true));
}
Program: 3234
Project: 3234
Buggy source:
public static INDArray tailor3d2d(@NonNull INDArray data,INDArray mask){
  int instances=data.size(0);
  int features=data.size(1);
  int timesteps=data.size(2);
  boolean hasMasks=mask != null;
  INDArray in2d=Nd4j.create(features,timesteps * instances);
  int tads=data.tensorssAlongDimension(2,0);
  for (int i=0; i < tads; i++) {
    INDArray thisTAD=data.tensorAlongDimension(i,2,0);
    if (hasMasks)     thisTAD.muli(mask);
    in2d.putRow(i,Nd4j.toFlattened('c',thisTAD));
  }
  in2d=in2d.transpose();
  if (hasMasks) {
    INDArray columnMask=Nd4j.toFlattened('c',mask).transpose();
    int actualSamples=columnMask.sumNumber().intValue();
    INDArray in2dMask=Nd4j.create(actualSamples,features);
    int i=0;
    for (int j=0; j < instances; j++) {
      for (int k=0; k < timesteps; k++) {
        if (columnMask.getInt(j * timesteps + k,0) != 0) {
          in2dMask.putRow(i,in2d.getRow(j * timesteps + k));
          i++;
        }
 else {
          continue;
        }
      }
    }
    return in2dMask;
  }
  return in2d;
}

Fixed version (ground truth):
public static INDArray tailor3d2d(@NonNull INDArray data,INDArray mask){
  int instances=data.size(0);
  int features=data.size(1);
  int timesteps=data.size(2);
  boolean hasMasks=mask != null;
  INDArray in2d=Nd4j.create(features,timesteps * instances);
  int tads=data.tensorssAlongDimension(2,0);
  for (int i=0; i < tads; i++) {
    INDArray thisTAD=data.tensorAlongDimension(i,2,0);
    if (hasMasks)     thisTAD.muli(mask);
    in2d.putRow(i,Nd4j.toFlattened('c',thisTAD));
  }
  in2d=in2d.transpose();
  if (hasMasks) {
    INDArray columnMask=Nd4j.toFlattened('c',mask).transpose();
    int actualSamples=columnMask.sumNumber().intValue();
    if (actualSamples == 0) {
      return null;
    }
    INDArray in2dMask=Nd4j.create(actualSamples,features);
    int i=0;
    for (int j=0; j < instances; j++) {
      for (int k=0; k < timesteps; k++) {
        if (columnMask.getInt(j * timesteps + k,0) != 0) {
          in2dMask.putRow(i,in2d.getRow(j * timesteps + k));
          i++;
        }
 else {
          continue;
        }
      }
    }
    return in2dMask;
  }
  return in2d;
}
Program: 3235
Project: 3235
Buggy source:
public TestMultiDataSetIterator(MultiDataSet dataset,int batch){
  list=new ArrayList<>(dataset.asList());
  this.batch=batch;
}

Fixed version (ground truth):
/** 
 * Makes an iterator from the given datasets. DataSets are expected to are batches of exactly 1 example. ONLY for use in tests in nd4j
 */
public TestMultiDataSetIterator(int batch,MultiDataSet... dataset){
  list=Arrays.asList(dataset);
  this.batch=batch;
}
Program: 3236
Project: 3236
Buggy source:
@Test public void testFullyMaskedData(){
  data=new MultiDataSet(new INDArray[]{Nd4j.create(new float[]{1,2}).reshape(1,1,2)},new INDArray[]{Nd4j.create(new float[]{2,3}).reshape(1,1,2)},new INDArray[]{Nd4j.create(new float[]{1,1}).reshape(1,2)},new INDArray[]{Nd4j.create(new float[]{0,0}).reshape(1,2)});
  SUT.fit(data);
}

Fixed version (ground truth):
@Test public void testFullyMaskedData(){
  MultiDataSetIterator iter=new TestMultiDataSetIterator(1,new MultiDataSet(new INDArray[]{Nd4j.create(new float[]{1}).reshape(1,1,1)},new INDArray[]{Nd4j.create(new float[]{2}).reshape(1,1,1)}),new MultiDataSet(new INDArray[]{Nd4j.create(new float[]{2}).reshape(1,1,1)},new INDArray[]{Nd4j.create(new float[]{4}).reshape(1,1,1)},null,new INDArray[]{Nd4j.create(new float[]{0}).reshape(1,1)}));
  SUT.fit(iter);
  assertEquals(2f,SUT.getLabelMean(0).getFloat(0),1e-6);
}
Program: 3237
Project: 3237
Buggy source:
@Test public void testMultipleInputsAndOutputsWithIterator(){
  MultiDataSetIterator iter=new TestMultiDataSetIterator(data,5);
  SUT.fit(iter);
  assertExpectedMeanStd();
}

Fixed version (ground truth):
@Test public void testMultipleInputsAndOutputsWithIterator(){
  MultiDataSetIterator iter=new TestMultiDataSetIterator(1,data);
  SUT.fit(iter);
  assertExpectedMeanStd();
}
Program: 3238
Project: 3238
Buggy source:
/** 
 * Add rows of data to the statistics
 * @param data the matrix containing multiple rows of data to include
 * @param mask (optionally) the mask of the data, useful for e.g. time series
 */
public Builder add(@NonNull INDArray data,INDArray mask){
  data=DataSetUtil.tailor2d(data,mask);
  INDArray mean=data.mean(0);
  INDArray variance=data.var(false,0);
  int count=data.size(0);
  if (runningMean == null) {
    runningMean=mean;
    runningVariance=variance;
    runningCount=count;
  }
 else {
    INDArray deltaSquared=Transforms.pow(mean.subRowVector(runningMean),2);
    INDArray mB=variance.muli(count);
    runningVariance.muli(runningCount).addiRowVector(mB).addiRowVector(deltaSquared.muli((float)(runningCount * count) / (runningCount + count))).divi(runningCount + count);
    runningCount+=count;
    INDArray xMinusMean=data.subRowVector(runningMean);
    runningMean.addi(xMinusMean.sum(0).divi(runningCount));
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Add rows of data to the statistics
 * @param data the matrix containing multiple rows of data to include
 * @param mask (optionally) the mask of the data, useful for e.g. time series
 */
public Builder add(@NonNull INDArray data,INDArray mask){
  data=DataSetUtil.tailor2d(data,mask);
  int count=data.size(0);
  if (count == 0) {
    return this;
  }
  INDArray mean=data.mean(0);
  INDArray variance=data.var(false,0);
  if (runningMean == null) {
    runningMean=mean;
    runningVariance=variance;
    runningCount=count;
  }
 else {
    INDArray deltaSquared=Transforms.pow(mean.subRowVector(runningMean),2);
    INDArray mB=variance.muli(count);
    runningVariance.muli(runningCount).addiRowVector(mB).addiRowVector(deltaSquared.muli((float)(runningCount * count) / (runningCount + count))).divi(runningCount + count);
    runningCount+=count;
    INDArray xMinusMean=data.subRowVector(runningMean);
    runningMean.addi(xMinusMean.sum(0).divi(runningCount));
  }
  return this;
}
Program: 3239
Project: 3239
Buggy source:
/** 
 * @param idx the index to pullRows the string label value out of the list if it exists
 * @return the label name
 */
@Override public String getLabelName(int idx){
  return labelNames.get(idx);
}

Fixed version (ground truth):
/** 
 * @param idx the index to pullRows the string label value out of the list if it exists
 * @return the label name
 */
@Override public String getLabelName(int idx){
  if (!labelNames.isEmpty()) {
    if (idx < labelNames.size())     return labelNames.get(idx);
 else     throw new IllegalStateException("String_Node_Str");
  }
 else   throw new IllegalStateException("String_Node_Str");
}
Program: 3240
Project: 3240
Buggy source:
/** 
 * Returns a subset of this array based on the specified indexes
 * @param indexes the indexes in to the array
 * @return a view of the array with the specified indices
 */
@Override public INDArray get(INDArrayIndex... indexes){
  if (indexes.length == 1 && indexes[0] instanceof NDArrayIndexAll)   return this;
  ShapeOffsetResolution resolution=new ShapeOffsetResolution(this);
  resolution.exec(indexes);
  if (indexes.length < 1)   throw new IllegalStateException("String_Node_Str");
  int[] shape=resolution.getShapes();
  if (indexes[0] instanceof SpecifiedIndex) {
    INDArray ret=create(shape);
    int count=0;
    if (isVector()) {
      indexes[0].reset();
      while (indexes[0].hasNext()) {
        ret.putScalar(count++,getDouble(indexes[0].next()));
      }
    }
 else {
      while (indexes[0].hasNext()) {
        int nextIdx=indexes[0].next();
        INDArray next=slice(nextIdx);
        if (indexes.length > 1) {
          INDArray slice=next.get(Arrays.copyOfRange(indexes,1,indexes.length));
          ret.putSlice(count++,slice);
        }
 else         if (next.isScalar()) {
          ret.putScalar(count++,next.getDouble(0));
        }
 else         if (next.isVector()) {
          ret.putSlice(count++,next);
        }
 else         ret.putSlice(count++,next.get(indexes));
      }
    }
    return ret;
  }
  INDArray ret=subArray(resolution);
  return ret;
}

Fixed version (ground truth):
/** 
 * Returns a subset of this array based on the specified indexes
 * @param indexes the indexes in to the array
 * @return a view of the array with the specified indices
 */
@Override public INDArray get(INDArrayIndex... indexes){
  if (indexes.length == 1 && indexes[0] instanceof NDArrayIndexAll)   return this;
  ShapeOffsetResolution resolution=new ShapeOffsetResolution(this);
  resolution.exec(indexes);
  if (indexes.length < 1)   throw new IllegalStateException("String_Node_Str");
  int[] shape=resolution.getShapes();
  if (shape != null && indexes[0] instanceof SpecifiedIndex) {
    INDArray ret=create(shape);
    int count=0;
    if (isVector()) {
      indexes[0].reset();
      while (indexes[0].hasNext()) {
        ret.putScalar(count++,getDouble(indexes[0].next()));
      }
    }
 else {
      while (indexes[0].hasNext()) {
        int nextIdx=indexes[0].next();
        INDArray next=slice(nextIdx);
        if (indexes.length > 1) {
          INDArray slice=next.get(Arrays.copyOfRange(indexes,1,indexes.length));
          ret.putSlice(count++,slice);
        }
 else         if (next.isScalar()) {
          ret.putScalar(count++,next.getDouble(0));
        }
 else         if (next.isVector()) {
          ret.putSlice(count++,next);
        }
 else         ret.putSlice(count++,next.get(indexes));
      }
    }
    return ret;
  }
  INDArray ret=subArray(resolution);
  return ret;
}
Program: 3241
Project: 3241
Buggy source:
/** 
 * Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
 * @param s
 * @return
 */
public static DataBuffer readUnknown(DataInputStream s,long length){
  DataBuffer buffer=Nd4j.createBuffer(length);
  buffer.read(s);
  if (buffer.dataType() != Type.COMPRESSED)   return buffer;
 else {
    try {
      String compressionAlgorithm=s.readUTF();
      long compressedLength=s.readLong();
      long originalLength=s.readLong();
      long numberOfElements=s.readLong();
      byte[] temp=new byte[(int)compressedLength];
      for (int i=0; i < compressedLength; i++) {
        temp[i]=s.readByte();
      }
      Pointer pointer=new BytePointer(temp);
      CompressionDescriptor descriptor=new CompressionDescriptor();
      descriptor.setCompressedLength(compressedLength);
      descriptor.setCompressionAlgorithm(compressionAlgorithm);
      descriptor.setOriginalLength(originalLength);
      descriptor.setNumberOfElements(numberOfElements);
      CompressedDataBuffer compressedBuffer=new CompressedDataBuffer(pointer,descriptor);
      return Nd4j.getCompressor().decompress(compressedBuffer);
    }
 catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
 * @param s
 * @return
 */
public static DataBuffer readUnknown(DataInputStream s,long length){
  DataBuffer buffer=Nd4j.createBuffer(length);
  buffer.read(s);
  if (buffer.dataType() != Type.COMPRESSED)   return buffer;
 else {
    try {
      String compressionAlgorithm=s.readUTF();
      long compressedLength=s.readLong();
      long originalLength=s.readLong();
      long numberOfElements=s.readLong();
      byte[] temp=new byte[(int)compressedLength];
      for (int i=0; i < compressedLength; i++) {
        temp[i]=s.readByte();
      }
      try (Pointer pointer=new BytePointer(temp)){
        CompressionDescriptor descriptor=new CompressionDescriptor();
        descriptor.setCompressedLength(compressedLength);
        descriptor.setCompressionAlgorithm(compressionAlgorithm);
        descriptor.setOriginalLength(originalLength);
        descriptor.setNumberOfElements(numberOfElements);
        CompressedDataBuffer compressedBuffer=new CompressedDataBuffer(pointer,descriptor);
        return Nd4j.getCompressor().decompress(compressedBuffer);
      }
     }
 catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
}