Practical use case for _extra_files?

Can someone help me understand when and how to use the _extra_files parameter is and torch.jit.load? The code example in the documents (with extra_files['foo.txt'] = 'bar') didn’t help me understand what its practical use would be.

It lets you wrap up any extra data you want into the output of and have it be decoded for you by torch.load. Maybe you want to ship some documentation or versioning metadata with your saved model to help with deployment, extra_files lets you do that without having to ship files separately alongside your .pt file.

The .pt file from is a zip file, so any extra_files just get added to the zip archive.

To dig into the docs example a little more, for this code:

class M(nn.Module):
    def forward(self):

m = torch.jit.script(M())
extra_files = torch._C.ExtraFilesMap()
extra_files['foo.txt'] = 'bar', '', _extra_files=extra_files)

Then in a shell

$ unzip
 extracting: scriptmodule/version    
 extracting: scriptmodule/extra/foo.txt  
 extracting: scriptmodule/data.pkl   
 extracting: scriptmodule/code/  
 extracting: scriptmodule/code/  
 extracting: scriptmodule/constants.pkl  
$ cat scriptmodule/extra/foo.txt