Gets rid of any singleton dimensions of the given array

@param shape the shape to squeeze
@return the array with all of the singleton dimensions removed
14913
public static long[] squeeze(long[] shape) {
        if (isColumnVectorShape(shape))
            return shape;

        List<Long> ret = new ArrayList<>();

        //strip all but last dimension
        for (int i = 0; i < shape.length; i++)
            if (shape[i] != 1)
                ret.add(shape[i]);
        return ArrayUtil.toArrayLong(ret);
    }
1293399
public static long[] getMaxShape(INDArray...inputs) {
        if(inputs == null)
            return null;
        else if(inputs.length < 2)
            return inputs[0].shape();
        else {
            long[] currMax = inputs[0].shape();
            for(int i = 1; i <  inputs.length; i++) {
                if(inputs[i] == null) {
                    continue;
                }
                if(ArrayUtil.prod(currMax) < inputs[i].length()) {
                    currMax = inputs[i].shape();
                }
            }

            return currMax;
        }
    }
267395
public List<LongShapeDescriptor> calculateOutputShape() {
        if(x == null || y == null)
            return Collections.emptyList();

        long[] shapeX = x.shape();
        long[] shapeY = y.shape();

        return Collections.singletonList(LongShapeDescriptor.fromShape(Shape.broadcastOutputShape(shapeX, shapeY),
                Shape.pickPairwiseDataType(x.dataType(), y.dataType())));
    }
269845
public Rectangle[] getDirtyRegions ()
    {
        List<Rectangle> merged = Lists.newArrayList();

        for (int ii = _dirty.size() - 1; ii >= 0; ii--) {
            // pop the next rectangle from the dirty list
            Rectangle mr = _dirty.remove(ii);

            // merge in any overlapping rectangles
            for (int jj = ii - 1; jj >= 0; jj--) {
                Rectangle r = _dirty.get(jj);
                if (mr.intersects(r)) {
                    // remove the overlapping rectangle from the list
                    _dirty.remove(jj);
                    ii--;
                    // grow the merged dirty rectangle
                    mr.add(r);
                }
            }

            // add the merged rectangle to the list
            merged.add(mr);
        }

        return merged.toArray(new Rectangle[merged.size()]);
    }
1199253
public static int[] ind2subC(int[] shape, long index, long numIndices) {
        long denom = numIndices;
        int[] ret = new int[shape.length];
        for (int i = 0; i < shape.length; i++) {
            denom /= shape[i];
            if (index / denom >= Integer.MAX_VALUE)
                throw new IllegalArgumentException("Dimension can not be >= Integer.MAX_VALUE");
            ret[i] = (int) (index / denom);
            index %= denom;

        }
        return ret;
    }
820601
public static INDArray reshapeWeights(long[] shape, INDArray paramsView, char flatteningOrder) {
        return paramsView.reshape(flatteningOrder, shape);
    }
421195
private Shape decodeShadow(int width, int height) {
        path.reset();
        path.moveTo(width - 1, 0);
        path.lineTo(width - 1, height - 4);
        path.lineTo(width - 4, height - 1);
        path.lineTo(0, height - 1);

        return path;
    }
258956
public List<LongShapeDescriptor> calculateOutputShape() {
        if(x == null || y == null)
            return Collections.emptyList();

        long[] shapeX = x.shape();
        long[] shapeY = y.shape();

        return Collections.singletonList(LongShapeDescriptor.fromShape(Shape.broadcastOutputShape(shapeX, shapeY), DataType.BOOL));
    }
884419
public static int[] dimensions(Object arr) {
        int[] dims = new int[Types.arrayDimensions(arr.getClass())];
        if ( 0 == dims.length || 0 == (dims[0] = Array.getLength(arr)) )
            return dims;
        for ( int i = 1; i < dims.length; i++ )
            if ( null != (arr = Array.get(arr, 0)) )
                dims[i] = Array.getLength(arr);
            else break;
        return dims;
    }
1206498
public static boolean validFill(Shape shape) {
    	if (shape.getTriangles() == null) {
    		return false;
    	}
        return shape.getTriangles().getTriangleCount() != 0;
    }
1115563
def Squeeze(a, squeeze_dims):
    
    if not squeeze_dims:
        squeeze_dims = list(range(len(a.shape)))
    slices = [(0 if (dim == 1 and i in squeeze_dims) else slice(None)) \
              for i, dim in enumerate(a.shape)]
    return np.copy(a)[slices],
506705
def get_shape_mask(self, shape_obj):
        
        wd, ht = self.get_size()
        yi = np.mgrid[:ht].reshape(-1, 1)
        xi = np.mgrid[:wd].reshape(1, -1)
        pts = np.asarray((xi, yi)).T
        contains = shape_obj.contains_pts(pts)
        return contains
964574
public static INDArray generate(long[] shape, char order, Values values){
        switch (values){
            case RANDOM_UNIFORM:
                return Nd4j.rand(Nd4j.createUninitialized(shape,order));
            case RANDOM_NORMAL:
                return Nd4j.randn(Nd4j.createUninitialized(shape,order));
            case ONE_HOT:
                Random r = new Random(Nd4j.getRandom().nextLong());
                INDArray out = Nd4j.create(shape,order);
                if(shape.length == 1){
                    out.putScalar(r.nextInt((int) shape[0]), 1.0);
                } else if(shape.length == 2){
                    for( int i=0; i<shape[0]; i++ ){
                        out.putScalar(i, r.nextInt((int) shape[1]), 1.0);
                    }
                } else if(shape.length == 3){
                    for( int i=0; i<shape[0]; i++ ){
                        for(int j=0; j<shape[2]; j++ ){
                            out.putScalar(i, r.nextInt((int) shape[1]), j, 1.0);
                        }
                    }
                } else if(shape.length == 4){
                    for( int i=0; i<shape[0]; i++ ){
                        for(int j=0; j<shape[2]; j++ ){
                            for(int k=0; k<shape[3]; k++ ) {
                                out.putScalar(i, r.nextInt((int) shape[1]), j, k, 1.0);
                            }
                        }
                    }
                } else if(shape.length == 5){
                    for( int i=0; i<shape[0]; i++ ){
                        for(int j=0; j<shape[2]; j++ ){
                            for(int k=0; k<shape[3]; k++ ) {
                                for( int l=0; l<shape[4]; l++ ) {
                                    out.putScalar(new int[]{i, r.nextInt((int) shape[1]), j, k, l}, 1.0);
                                }
                            }
                        }
                    }
                } else {
                    throw new RuntimeException("Not supported: rank 6+ arrays. Shape: " + Arrays.toString(shape));
                }
                return out;
            case ZEROS:
                return Nd4j.create(shape,order);
            case ONES:
                return Nd4j.createUninitialized(shape,order).assign(1.0);
            case BINARY:
                return Nd4j.getExecutioner().exec(new BernoulliDistribution(Nd4j.createUninitialized(shape, order), 0.5));
            case INTEGER_0_10:
                return Transforms.floor(Nd4j.rand(shape).muli(10), false);
            case INTEGER_0_100:
                return Transforms.floor(Nd4j.rand(shape).muli(100), false);
            case INTEGER_0_1000:
                return Transforms.floor(Nd4j.rand(shape).muli(1000), false);
            case INTEGER_0_10000:
                return Transforms.floor(Nd4j.rand(shape).muli(10000), false);
            case INTEGER_0_100000:
                return Transforms.floor(Nd4j.rand(shape).muli(100000), false);
            default:
                throw new RuntimeException("Unknown enum value: " + values);

        }
    }
1130265
public static long lengthOfBuffer(@NonNull long[] shape, @NonNull long[] stride){
        Preconditions.checkArgument(shape.length == stride.length, "Shape and strides must be same length: shape %s, stride %s",
                shape, stride);
        //Length is simply 1 + the buffer index of the last element
        long length = 1;
        for(int i=0; i<shape.length; i++ ){
            length += (shape[i]-1) * stride[i];
        }
        return length;
    }
123593
@SuppressWarnings("unchecked")
    static <T> Node<T> emptyNode(StreamShape shape) {
        switch (shape) {
            case REFERENCE:    return (Node<T>) EMPTY_NODE;
            case INT_VALUE:    return (Node<T>) EMPTY_INT_NODE;
            case LONG_VALUE:   return (Node<T>) EMPTY_LONG_NODE;
            case DOUBLE_VALUE: return (Node<T>) EMPTY_DOUBLE_NODE;
            default:
                throw new IllegalStateException("Unknown shape " + shape);
        }
    }
434982
public long[] transposeShapeArray(long[] shape) {
        if (shape.length == 2) {
            return ArrayUtil.reverseCopy(shape);
        } else if (shape.length == 3) {
            return new long[] {shape[0], shape[2], shape[1]};
        } else {
            throw new IllegalArgumentException("Matrix input has to be of length 2 or 3, got: " + shape.length );
        }

    }
194502
@Override
    public INDArray create(List<INDArray> list, int[] shape) {
        return new NDArray(list, shape, Nd4j.getStrides(shape));
    }