code: @Override
      public void collect(INDArray... arrays) {
          // we basically want to free memory, without touching INDArray itself.
          // so we don't care when gc is going to release object: memory is already cached
  
          Nd4j.getExecutioner().commit();
  
          int cnt = -1;
          AtomicAllocator allocator = AtomicAllocator.getInstance();
          for (INDArray array : arrays) {
              cnt++;
              // we don't collect views, since they don't have their own memory
              if (array == null || array.isView())
                  continue;
  
              AllocationPoint point = allocator.getAllocationPoint(array);
  
              if (point.getAllocationStatus() == AllocationStatus.HOST)
                  allocator.getMemoryHandler().free(point, AllocationStatus.HOST);
              else if (point.getAllocationStatus() == AllocationStatus.DEVICE) {
                  allocator.getMemoryHandler().free(point, AllocationStatus.DEVICE);
                  allocator.getMemoryHandler().free(point, AllocationStatus.HOST);
              } else if (point.getAllocationStatus() == AllocationStatus.DEALLOCATED) {
                  // do nothing
              } else
                  throw new RuntimeException(
                                  "Unknown AllocationStatus: " + point.getAllocationStatus() + " for argument: " + cnt);
  
              point.setAllocationStatus(AllocationStatus.DEALLOCATED);
          }
      }
docs: This method detaches off-heap memory from passed INDArray instances, and optionally stores them in cache for future reuse
  PLEASE NOTE: Cache options depend on specific implementations
  
  @param arrays