@Override
    public void close() throws IllegalStateException {
        try {
            session.close();
        } catch (UncheckedOrtException e) {
            throw new IllegalStateException("Failed to close ONNX session", e);
        } catch (IllegalStateException e) {
            throw new IllegalStateException("Already closed", e);
        }
    }
@Test
    public void testLoggingMessages() throws IOException {
        assumeTrue(OnnxRuntime.isRuntimeAvailable());
        Logger logger = Logger.getLogger(OnnxEvaluator.class.getName());
        CustomLogHandler logHandler = new CustomLogHandler();
        logger.addHandler(logHandler);
        var runtime = new OnnxRuntime();
        var model = Files.readAllBytes(Paths.get("src/test/models/onnx/simple/simple.onnx"));
        OnnxEvaluatorOptions options = new OnnxEvaluatorOptions();
        options.setGpuDevice(0);
        var evaluator = runtime.evaluatorOf(model,options);
        evaluator.close();
        List<LogRecord> records = logHandler.getLogRecords();
        assertEquals(1,records.size());
        assertEquals(Level.INFO,records.get(0).getLevel());
        String message = records.get(0).getMessage();
        assertEquals("Failed to create session with CUDA using GPU device 0. " +
                "Falling back to CPU. Reason: Error code - ORT_EP_FAIL - message:" +
                " Failed to find CUDA shared provider", message);
        logger.removeHandler(logHandler);

    }