yobx.torch#

main functions

register_flattening_functions#

yobx.torch.register_flattening_functions(patch_transformers: bool = False, verbose: int = 0) Generator[Callable, None, None][source]#

The context manager registers flattening functions the exporter needs to handle any custom class. This is used to create a signature taking only tensors as inputs even though the code shows nested structures.

from yobx.torch import register_flattening_functions

with register_flattening_functions(patch_transformers=True):
    # ...