qml.workflow.interfaces.torch.pytreeify

pytreeify(cls)[source]

Pytrees refer to a tree-like structure built out of container-like Python objects. The pytreeify class is used to bypass some PyTorch limitation of autograd.Function. The forward pass can only return tuple of tensors but not any other nested structure. This class apply flatten to the forward pass and unflatten the results in the apply function. In this way, it is possible to treat multiple tapes with multiple measurements.