def remove_by_id(lst, value):
    """Remove a value from a list by id."""
    for i, v in enumerate(lst):
        if id(v) == id(value):
            del lst[i]
            return
Remove a value from a list by id.
keras/src/utils/python_utils.py