Find module corresponding to the method in python
I am learning to work with fastai. And I come across this:
xt = tensor(3.).requires_grad_()
xt
[out1]: tensor(3., requires_grad=True)

I want to know where requires_grad_() is from i.e., is it from fastai or is it pytorch related. So I do:
requires_grad_.__module__
[out2]: NameError: name 'require_grad_' is not defined

What am I doing wrong? What am I missing?

Err
The key is you cannot access requires_grad_ directly. requires_grad_ is not a global object, it is a member method of xt, so you cannot access it directly (when you do this, you'll get  the not define error),  the way to access it is through the class instance it belongs to (xt), like print(xt.requires_grad_.__module__).
Test
According to doc on python.org, all of function, member method, class and class instance have __module__ attr. So the code print(xt.requires_grad_.__module__) should work, but when I tested the code
print(xt.requires_grad_.__module__)

and got output None rather than torch I expect, which is a litte bit wierd. I guess for torch Tensor's member method, this __module__ varible is unavailable. So then I tested another case (print the __module__ attr of a member method for another class DataFrame):
from pandas import DataFrame
a = DataFrame()
a.min.__module__

and I got output pandas.core.frame which means we do can get __module__ attr from a member method object.
However, in you case, the fastest way is to get the module of xt, since a class method must belongs to the module of its class instance, so you can just use
print(xt.__module__)

and you will get correct module name: torch.
BTW, requires_grad_ belongs to torch.Tensor which belongs to torch module, at backprop phase, this func set a bool flag that tells torch whether gradient of tensor `xt
