def listify_tensors(x):
    """Convert any tensors or numpy arrays to lists for config serialization."""
    if tf.is_tensor(x):
        x = x.numpy()
    if isinstance(x, np.ndarray):
        x = x.tolist()
    return x
Convert any tensors or numpy arrays to lists for config serialization.
keras/src/layers/preprocessing/index_lookup.py