Program: 3271
Project: 3271
Buggy source:
/** 
 * Broadcasts this ndarray to be the specified shape
 * @param shape the new shape of this ndarray
 * @return the broadcasted ndarray
 */
@Override public INDArray broadcast(int... shape){
  if (Shape.shapeEquals(shape,shape()))   return this;
  boolean compatible=true;
  int count=shape.length - 1;
  int thisCount=Shape.rank(shapeInformation.asNioInt()) - 1;
  for (int i=shape.length - 1; i > 0; i--) {
    if (count < 0 || thisCount < 0)     break;
    if (shape[count] != shape()[thisCount] && shape[count] != 1 && shape()[thisCount] != 1) {
      compatible=false;
      break;
    }
    count--;
    thisCount--;
  }
  if (!compatible)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape()) + "String_Node_Str"+ Arrays.toString(shape));
  int[] retShape=new int[shape.length];
  List<Integer> broadCastDimensions=new ArrayList<>();
  List<Integer> nonBroadCastDimensions=new ArrayList<>();
  for (int i=0; i < retShape.length; i++) {
    if (shape().length == 1) {
      if (i == 0) {
        if (i < shape().length)         retShape[i]=Math.max(1,shape[i]);
 else         retShape[i]=shape[i];
      }
 else {
        if (i < shape().length)         retShape[i]=Math.max(shape[i],size(i));
 else         retShape[i]=shape[i];
      }
    }
 else {
      if (i < rank() && size(i) == 1)       broadCastDimensions.add(i);
 else       nonBroadCastDimensions.add(i);
      if (i < shape().length)       retShape[i]=Math.max(shape[i],size(i));
 else       retShape[i]=shape[i];
    }
  }
  INDArray ret=create(retShape,ordering());
  if (isRowVector()) {
    for (int i=0; i < ret.slices(); i++) {
      ret.putSlice(i,this);
    }
  }
 else {
    int repeatDelta=ArrayUtil.prod(retShape) / length();
    for (int i=0; i < slices(); i++) {
      INDArray thisTensor=slice(i);
      INDArray retTensor=ret.slice(i);
      int retIdx=0;
      int tensorLen=thisTensor.rank();
      outer:       for (int k=0; k < tensorLen; k++) {
        for (int j=0; j < repeatDelta; j++) {
          if (retIdx >= retTensor.length())           break outer;
          retTensor.putScalar(retIdx++,thisTensor.getDouble(k));
        }
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Broadcasts this ndarray to be the specified shape
 * @param shape the new shape of this ndarray
 * @return the broadcasted ndarray
 */
@Override public INDArray broadcast(int... shape){
  if (Shape.shapeEquals(shape,shape()))   return this;
  boolean compatible=true;
  int count=shape.length - 1;
  int thisCount=Shape.rank(shapeInformation) - 1;
  for (int i=shape.length - 1; i > 0; i--) {
    if (count < 0 || thisCount < 0)     break;
    if (shape[count] != shape()[thisCount] && shape[count] != 1 && shape()[thisCount] != 1) {
      compatible=false;
      break;
    }
    count--;
    thisCount--;
  }
  if (!compatible)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape()) + "String_Node_Str"+ Arrays.toString(shape));
  int[] retShape=new int[shape.length];
  List<Integer> broadCastDimensions=new ArrayList<>();
  List<Integer> nonBroadCastDimensions=new ArrayList<>();
  for (int i=0; i < retShape.length; i++) {
    if (shape().length == 1) {
      if (i == 0) {
        if (i < shape().length)         retShape[i]=Math.max(1,shape[i]);
 else         retShape[i]=shape[i];
      }
 else {
        if (i < shape().length)         retShape[i]=Math.max(shape[i],size(i));
 else         retShape[i]=shape[i];
      }
    }
 else {
      if (i < rank() && size(i) == 1)       broadCastDimensions.add(i);
 else       nonBroadCastDimensions.add(i);
      if (i < shape().length)       retShape[i]=Math.max(shape[i],size(i));
 else       retShape[i]=shape[i];
    }
  }
  INDArray ret=create(retShape,ordering());
  if (isRowVector()) {
    for (int i=0; i < ret.slices(); i++) {
      ret.putSlice(i,this);
    }
  }
 else {
    int repeatDelta=ArrayUtil.prod(retShape) / length();
    for (int i=0; i < slices(); i++) {
      INDArray thisTensor=slice(i);
      INDArray retTensor=ret.slice(i);
      int retIdx=0;
      int tensorLen=thisTensor.rank();
      outer:       for (int k=0; k < tensorLen; k++) {
        for (int j=0; j < repeatDelta; j++) {
          if (retIdx >= retTensor.length())           break outer;
          retTensor.putScalar(retIdx++,thisTensor.getDouble(k));
        }
      }
    }
  }
  return ret;
}