### Question:
ProtectedCudaShapeInfoProvider extends BaseShapeInfoProvider { public static ProtectedCudaShapeInfoProvider getInstance() { return ourInstance; } private  ProtectedCudaShapeInfoProvider(); @Override void purgeCache(); static ProtectedCudaShapeInfoProvider getInstance(); @Override Pair<DataBuffer, long[]> createShapeInformation(int[] shape, int[] stride, long offset, int elementWiseStride, char order); @Override Pair<DataBuffer, long[]> createShapeInformation(long[] shape, long[] stride, long offset, long elementWiseStride, char order);  }### Answer:
@Test public void testPurge1() throws Exception { INDArray array = Nd4j.create(10, 10); ProtectedCudaShapeInfoProvider provider = (ProtectedCudaShapeInfoProvider) ProtectedCudaShapeInfoProvider.getInstance(); assertEquals(true, provider.protector.containsDataBuffer(0, new ShapeDescriptor(array.shape(), array.stride(),0, array.elementWiseStride(), array.ordering()))); Nd4j.getMemoryManager().purgeCaches(); assertEquals(false, provider.protector.containsDataBuffer(0, new ShapeDescriptor(array.shape(), array.stride(),0, array.elementWiseStride(), array.ordering()))); }
@Test public void testPurge2() throws Exception { INDArray arrayA = Nd4j.create(10, 10); DataBuffer shapeInfoA = arrayA.shapeInfoDataBuffer(); INDArray arrayE = Nd4j.create(10, 10); DataBuffer shapeInfoE = arrayE.shapeInfoDataBuffer(); int[] arrayShapeA = shapeInfoA.asInt(); assertTrue(shapeInfoA == shapeInfoE); ShapeDescriptor descriptor = new ShapeDescriptor(arrayA.shape(), arrayA.stride(), 0, arrayA.elementWiseStride(), arrayA.ordering()); ConstantProtector protector = ConstantProtector.getInstance(); AllocationPoint pointA = AtomicAllocator.getInstance().getAllocationPoint(arrayA.shapeInfoDataBuffer()); assertEquals(true, protector.containsDataBuffer(0, descriptor)); Nd4j.getMemoryManager().purgeCaches(); assertEquals(false, protector.containsDataBuffer(0, descriptor)); INDArray arrayB = Nd4j.create(10, 10); DataBuffer shapeInfoB = arrayB.shapeInfoDataBuffer(); assertFalse(shapeInfoA == shapeInfoB); AllocationPoint pointB = AtomicAllocator.getInstance().getAllocationPoint(arrayB.shapeInfoDataBuffer()); assertArrayEquals(arrayShapeA, shapeInfoB.asInt()); assertEquals(pointA.getPointers().getDevicePointer().address(), pointB.getPointers().getDevicePointer().address()); }