when using jax experimental enablex64 in unit test we want to keep the default dtype with 32 bits aligning it with keras s default when using torch and tensorflow torch needs to be imported first otherwise it will segfault upon import this should force the torch import to happen first for all tests when using jax experimental enable_x64 in unit test we want to keep the default dtype with 32 bits aligning it with keras s default when using torch and tensorflow torch needs to be imported first otherwise it will segfault upon import this should force the torch import to happen first for all tests noqa f401 noqa e402 noqa e402
import os



os.environ["JAX_DEFAULT_DTYPE_BITS"] = "32"

try:
    
    
    
    import torch  
except ImportError:
    pass

import pytest  

from keras.backend import backend  


def pytest_configure(config):
    config.addinivalue_line(
        "markers",
        "requires_trainable_backend: mark test for trainable backend only",
    )


def pytest_collection_modifyitems(config, items):
    requires_trainable_backend = pytest.mark.skipif(
        backend() == "numpy",
        reason="Trainer not implemented for NumPy backend.",
    )
    for item in items:
        if "requires_trainable_backend" in item.keywords:
            item.add_marker(requires_trainable_backend)