I'm new to this package, and I've figured out how to toggle layers on/off:
import pymupdfd
doc = pymupdf.open("file.pdf")
ogcs = doc.get_ocgs()
lyr_xref = ogcs[0]
doc.set_layer(-1, on=[lyr_xref], basestate="OFF") # turn off all but the first layer
But how do I delete them, or copy a specific layer to a new file?