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):
        super().__init__()
        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)
m_ts.save("m.pt")
exit()

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("m.pt")
m.extra_info
#> '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

True
None
ExtraString
<__torch__.torch.nn.modules.linear.Linear object at 0x5608d053eb20>
 0.9345
[ 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(p.name == "extra_info"){
                cout<<p.value<<endl;
            }
        }

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