qml.interfaces.torch.unflatten_torch

unflatten_torch(flat, model)[source]

Restores an arbitrary nested structure to a flattened Torch tensor.

Parameters
  • flat (torch.Tensor) – 1D tensor of items

  • model (array, Iterable, Number) – model nested structure

Returns

tuple containing elements of flat arranged into the nested structure of model, as well as the unused elements of flat.

Return type

Tuple[list[torch.Tensor], torch.Tensor]

Raises

TypeError – if model contains an object of unsupported type