Accessing non-parameter module member of torchscript model in C++

Suppose I have a simple torch model, and add an additional class member for saving some information, as shown below (extra_info).

import torch

class model(torch.nn.Module):
    def __init__(self):
        self.linear = torch.nn.Linear(1, 1)

    def forward(self, x):
        return self.linear(x)

m = model()
m.extra_info = "ExtraString"
m_ts = torch.jit.script(m)"")

Now when I reload the Torchscript module in python I can access the saved string easily, indicating that it has indeed been saved with the Torchscript model:

import torch
m = torch.jit.load("")
#> 'ExtraString'

But when I try to access it in C++ API, I obviously get error of no such member. How can I access extra_info field in C++?

I can see that the value is saved, and print it as:

for (auto p: model.attributes())
        {cout << p << endl;}

which prints the attributes as

<__torch__.torch.nn.modules.linear.Linear object at 0x5608d053eb20>
[ CPUFloatType{1,1} ]
0.01 *

But I cant figure out hot to fetch it specifically.

Figured it out

        for (auto p: model.named_attributes())
            if( == "extra_info"){

This yields required output. If anyone has better way to do it, I am all ears.