Repository: pytorch/pytorch

Issue:
Only FloatTensor has docstrings
Steps to repro:

```
>>> help(torch.FloatTensor())                                                                                                 
>>> help(torch.DoubleTensor())
```

This doesn't seem good. Is there a good reason we didn't attach docs to everything? I think it would be a simple matter of modifying `torch/_tensor_docs.py` to loop over all types (you'd also want to NOT add the docstring if the method doesn't exist). CC @apaszke who originally added docstring support.


Discussion:

Resolving patch:
diff --git a/torch/_storage_docs.py b/torch/_storage_docs.py
--- a/torch/_storage_docs.py
+++ b/torch/_storage_docs.py
@@ -15,26 +15,26 @@
 ]
 
 
-def add_docstr_all(classes, method, docstr):
-    for cls_name in classes:
+def add_docstr_all(method, docstr):
+    for cls_name in storage_classes:
         cls = getattr(torch._C, cls_name)
-        add_docstr(getattr(cls, method),
-                   docstr.format(
-                       cls_name.replace('Base', ''),
-                       cls_name.replace('StorageBase', '')))
+        try:
+            add_docstr(getattr(cls, method), docstr)
+        except AttributeError:
+            pass
 
 
-add_docstr_all(storage_classes, 'from_file',
+add_docstr_all('from_file',
                """
-from_file(filename, shared=False, size=0) -> {0}
+from_file(filename, shared=False, size=0) -> Storage
 
 If shared is True then memory is shared between all processes. All changes are
 written to the file. If shared is False then the changes on the storage do not
 affect the file.
 
 Size is the number of elements in the storage. If shared is False then the file
-must contain at least `size * sizeof({1})` bytes. If shared is True the file
-will be created if needed.
+must contain at least `size * sizeof(Type)` bytes (`Type` is the type of storage).
+If shared is True the file will be created if needed.
 
 Args:
     filename (str): file name to map
diff --git a/torch/_tensor_docs.py b/torch/_tensor_docs.py
--- a/torch/_tensor_docs.py
+++ b/torch/_tensor_docs.py
@@ -3,134 +3,155 @@
 import torch._C
 from torch._C import _add_docstr as add_docstr
 
-add_docstr(torch._C.FloatTensorBase.abs,
-           """
+
+tensor_classes = [
+    'DoubleTensorBase',
+    'FloatTensorBase',
+    'LongTensorBase',
+    'IntTensorBase',
+    'ShortTensorBase',
+    'CharTensorBase',
+    'ByteTensorBase',
+]
+
+
+def add_docstr_all(method, docstr):
+    for cls_name in tensor_classes:
+        cls = getattr(torch._C, cls_name)
+        try:
+            add_docstr(getattr(cls, method), docstr)
+        except AttributeError:
+            pass
+
+
+add_docstr_all('abs',
+               """
 abs() -> Tensor
 
 See :func:`torch.abs`
 """)
 
-add_docstr(torch._C.FloatTensorBase.abs_,
-           """
+add_docstr_all('abs_',
+               """
 abs_() -> Tensor
 
 In-place version of :meth:`~Tensor.abs`
 """)
 
-add_docstr(torch._C.FloatTensorBase.acos,
-           """
+add_docstr_all('acos',
+               """
 acos() -> Tensor
 
 See :func:`torch.acos`
 """)
 
-add_docstr(torch._C.FloatTensorBase.acos_,
-           """
+add_docstr_all('acos_',
+               """
 acos_() -> Tensor
 
 In-place version of :meth:`~Tensor.acos`
 """)
 
-add_docstr(torch._C.FloatTensorBase.add,
-           """
+add_docstr_all('add',
+               """
 add(value)
 
 See :func:`torch.add`
 """)
 
-add_docstr(torch._C.FloatTensorBase.add_,
-           """
+add_docstr_all('add_',
+               """
 add_(value)
 
 In-place version of :meth:`~Tensor.add`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addbmm,
-           """
+add_docstr_all('addbmm',
+               """
 addbmm(beta=1, mat, alpha=1, batch1, batch2) -> Tensor
 
 See :func:`torch.addbmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addbmm_,
-           """
+add_docstr_all('addbmm_',
+               """
 addbmm_(beta=1, mat, alpha=1, batch1, batch2) -> Tensor
 
 In-place version of :meth:`~Tensor.addbmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addcdiv,
-           """
+add_docstr_all('addcdiv',
+               """
 addcdiv(value=1, tensor1, tensor2) -> Tensor
 
 See :func:`torch.addcdiv`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addcdiv_,
-           """
+add_docstr_all('addcdiv_',
+               """
 addcdiv_(value=1, tensor1, tensor2) -> Tensor
 
 In-place version of :meth:`~Tensor.addcdiv`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addcmul,
-           """
+add_docstr_all('addcmul',
+               """
 addcmul(value=1, tensor1, tensor2) -> Tensor
 
 See :func:`torch.addcmul`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addcmul_,
-           """
+add_docstr_all('addcmul_',
+               """
 addcmul_(value=1, tensor1, tensor2) -> Tensor
 
 In-place version of :meth:`~Tensor.addcmul`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addmm,
-           """
+add_docstr_all('addmm',
+               """
 addmm(beta=1, mat, alpha=1, mat1, mat2) -> Tensor
 
 See :func:`torch.addmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addmm_,
-           """
+add_docstr_all('addmm_',
+               """
 addmm_(beta=1, mat, alpha=1, mat1, mat2) -> Tensor
 
 In-place version of :meth:`~Tensor.addmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addmv,
-           """
+add_docstr_all('addmv',
+               """
 addmv(beta=1, tensor, alpha=1, mat, vec) -> Tensor
 
 See :func:`torch.addmv`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addmv_,
-           """
+add_docstr_all('addmv_',
+               """
 addmv_(beta=1, tensor, alpha=1, mat, vec) -> Tensor
 
 In-place version of :meth:`~Tensor.addmv`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addr,
-           """
+add_docstr_all('addr',
+               """
 addr(beta=1, alpha=1, vec1, vec2) -> Tensor
 
 See :func:`torch.addr`
 """)
 
-add_docstr(torch._C.FloatTensorBase.addr_,
-           """
+add_docstr_all('addr_',
+               """
 addr_(beta=1, alpha=1, vec1, vec2) -> Tensor
 
 In-place version of :meth:`~Tensor.addr`
 """)
 
-add_docstr(torch._C.FloatTensorBase.apply_,
-           """
+add_docstr_all('apply_',
+               """
 apply_(callable) -> Tensor
 
 Applies the function :attr:`callable` to each element in the tensor, replacing
@@ -142,85 +163,85 @@
     sections that require high performance.
 """)
 
-add_docstr(torch._C.FloatTensorBase.asin,
-           """
+add_docstr_all('asin',
+               """
 asin() -> Tensor
 
 See :func:`torch.asin`
 """)
 
-add_docstr(torch._C.FloatTensorBase.asin_,
-           """
+add_docstr_all('asin_',
+               """
 asin_() -> Tensor
 
 In-place version of :meth:`~Tensor.asin`
 """)
 
-add_docstr(torch._C.FloatTensorBase.atan,
-           """
+add_docstr_all('atan',
+               """
 atan() -> Tensor
 
 See :func:`torch.atan`
 """)
 
-add_docstr(torch._C.FloatTensorBase.atan2,
-           """
+add_docstr_all('atan2',
+               """
 atan2(other) -> Tensor
 
 See :func:`torch.atan2`
 """)
 
-add_docstr(torch._C.FloatTensorBase.atan2_,
-           """
+add_docstr_all('atan2_',
+               """
 atan2_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.atan2`
 """)
 
-add_docstr(torch._C.FloatTensorBase.atan_,
-           """
+add_docstr_all('atan_',
+               """
 atan_() -> Tensor
 
 In-place version of :meth:`~Tensor.atan`
 """)
 
-add_docstr(torch._C.FloatTensorBase.baddbmm,
-           """
+add_docstr_all('baddbmm',
+               """
 baddbmm(beta=1, alpha=1, batch1, batch2) -> Tensor
 
 See :func:`torch.baddbmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.baddbmm_,
-           """
+add_docstr_all('baddbmm_',
+               """
 baddbmm_(beta=1, alpha=1, batch1, batch2) -> Tensor
 
 In-place version of :meth:`~Tensor.baddbmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.bernoulli,
-           """
+add_docstr_all('bernoulli',
+               """
 bernoulli() -> Tensor
 
 See :func:`torch.bernoulli`
 """)
 
-add_docstr(torch._C.FloatTensorBase.bernoulli_,
-           """
+add_docstr_all('bernoulli_',
+               """
 bernoulli_() -> Tensor
 
 In-place version of :meth:`~Tensor.bernoulli`
 """)
 
-add_docstr(torch._C.FloatTensorBase.bmm,
-           """
+add_docstr_all('bmm',
+               """
 bmm(batch2) -> Tensor
 
 See :func:`torch.bmm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cauchy_,
-           """
+add_docstr_all('cauchy_',
+               """
 cauchy_(median=0, sigma=1, *, generator=None) -> Tensor
 
 Fills the tensor with numbers drawn from the Cauchy distribution:
@@ -230,52 +251,52 @@
     P(x) = \dfrac{1}{\pi} \dfrac{\sigma}{(x - median)^2 + \sigma^2}
 """)
 
-add_docstr(torch._C.FloatTensorBase.ceil,
-           """
+add_docstr_all('ceil',
+               """
 ceil() -> Tensor
 
 See :func:`torch.ceil`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ceil_,
-           """
+add_docstr_all('ceil_',
+               """
 ceil_() -> Tensor
 
 In-place version of :meth:`~Tensor.ceil`
 """)
 
-add_docstr(torch._C.FloatTensorBase.clamp,
-           """
+add_docstr_all('clamp',
+               """
 clamp(min, max) -> Tensor
 
 See :func:`torch.clamp`
 """)
 
-add_docstr(torch._C.FloatTensorBase.clamp_,
-           """
+add_docstr_all('clamp_',
+               """
 clamp_(min, max) -> Tensor
 
 In-place version of :meth:`~Tensor.clamp`
 """)
 
-add_docstr(torch._C.FloatTensorBase.clone,
-           """
+add_docstr_all('clone',
+               """
 clone() -> Tensor
 
 Returns a copy of the tensor. The copy has the same size and data type as the
 original tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.contiguous,
-           """
+add_docstr_all('contiguous',
+               """
 contiguous() -> Tensor
 
 Returns a contiguous Tensor containing the same data as this tensor. If this
 tensor is contiguous, this function returns the original tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.copy_,
-           """
+add_docstr_all('copy_',
+               """
 copy_(src, async=False, broadcast=True) -> Tensor
 
 Copies the elements from :attr:`src` into this tensor and returns this tensor.
@@ -293,113 +314,113 @@
                       tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.cos,
-           """
+add_docstr_all('cos',
+               """
 cos() -> Tensor
 
 See :func:`torch.cos`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cos_,
-           """
+add_docstr_all('cos_',
+               """
 cos_() -> Tensor
 
 In-place version of :meth:`~Tensor.cos`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cosh,
-           """
+add_docstr_all('cosh',
+               """
 cosh() -> Tensor
 
 See :func:`torch.cosh`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cosh_,
-           """
+add_docstr_all('cosh_',
+               """
 cosh_() -> Tensor
 
 In-place version of :meth:`~Tensor.cosh`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cross,
-           """
+add_docstr_all('cross',
+               """
 cross(other, dim=-1) -> Tensor
 
 See :func:`torch.cross`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cumprod,
-           """
+add_docstr_all('cumprod',
+               """
 cumprod(dim) -> Tensor
 
 See :func:`torch.cumprod`
 """)
 
-add_docstr(torch._C.FloatTensorBase.cumsum,
-           """
+add_docstr_all('cumsum',
+               """
 cumsum(dim) -> Tensor
 
 See :func:`torch.cumsum`
 """)
 
-add_docstr(torch._C.FloatTensorBase.data_ptr,
-           """
+add_docstr_all('data_ptr',
+               """
 data_ptr() -> int
 
 Returns the address of the first element of this tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.diag,
-           """
+add_docstr_all('diag',
+               """
 diag(diagonal=0) -> Tensor
 
 See :func:`torch.diag`
 """)
 
-add_docstr(torch._C.FloatTensorBase.dim,
-           """
+add_docstr_all('dim',
+               """
 dim() -> int
 
 Returns the number of dimensions of this tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.dist,
-           """
+add_docstr_all('dist',
+               """
 dist(other, p=2) -> float
 
 See :func:`torch.dist`
 """)
 
-add_docstr(torch._C.FloatTensorBase.div,
-           """
+add_docstr_all('div',
+               """
 div(value)
 
 See :func:`torch.div`
 """)
 
-add_docstr(torch._C.FloatTensorBase.div_,
-           """
+add_docstr_all('div_',
+               """
 div_(value)
 
 In-place version of :meth:`~Tensor.div`
 """)
 
-add_docstr(torch._C.FloatTensorBase.dot,
-           """
+add_docstr_all('dot',
+               """
 dot(tensor2) -> float
 
 See :func:`torch.dot`
 """)
 
-add_docstr(torch._C.FloatTensorBase.eig,
-           """
+add_docstr_all('eig',
+               """
 eig(eigenvectors=False) -> (Tensor, Tensor)
 
 See :func:`torch.eig`
 """)
 
-add_docstr(torch._C.FloatTensorBase.element_size,
-           """
+add_docstr_all('element_size',
+               """
 element_size() -> int
 
 Returns the size in bytes of an individual element.
@@ -411,43 +432,43 @@
     1
 """)
 
-add_docstr(torch._C.FloatTensorBase.eq,
-           """
+add_docstr_all('eq',
+               """
 eq(other) -> Tensor
 
 See :func:`torch.eq`
 """)
 
-add_docstr(torch._C.FloatTensorBase.eq_,
-           """
+add_docstr_all('eq_',
+               """
 eq_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.eq`
 """)
 
-add_docstr(torch._C.FloatTensorBase.equal,
-           """
+add_docstr_all('equal',
+               """
 equal(other) -> bool
 
 See :func:`torch.equal`
 """)
 
-add_docstr(torch._C.FloatTensorBase.exp,
-           """
+add_docstr_all('exp',
+               """
 exp() -> Tensor
 
 See :func:`torch.exp`
 """)
 
-add_docstr(torch._C.FloatTensorBase.exp_,
-           """
+add_docstr_all('exp_',
+               """
 exp_() -> Tensor
 
 In-place version of :meth:`~Tensor.exp`
 """)
 
-add_docstr(torch._C.FloatTensorBase.exponential_,
-           """
+add_docstr_all('exponential_',
+               """
 exponential_(lambd=1, *, generator=None) -> Tensor
 
 Fills this tensor with elements drawn from the exponential distribution:
@@ -457,85 +478,85 @@
     P(x) = \lambda e^{-\lambda x}
 """)
 
-add_docstr(torch._C.FloatTensorBase.fill_,
-           """
+add_docstr_all('fill_',
+               """
 fill_(value) -> Tensor
 
 Fills this tensor with the specified value.
 """)
 
-add_docstr(torch._C.FloatTensorBase.floor,
-           """
+add_docstr_all('floor',
+               """
 floor() -> Tensor
 
 See :func:`torch.floor`
 """)
 
-add_docstr(torch._C.FloatTensorBase.floor_,
-           """
+add_docstr_all('floor_',
+               """
 floor_() -> Tensor
 
 In-place version of :meth:`~Tensor.floor`
 """)
 
-add_docstr(torch._C.FloatTensorBase.fmod,
-           """
+add_docstr_all('fmod',
+               """
 fmod(divisor) -> Tensor
 
 See :func:`torch.fmod`
 """)
 
-add_docstr(torch._C.FloatTensorBase.fmod_,
-           """
+add_docstr_all('fmod_',
+               """
 fmod_(divisor) -> Tensor
 
 In-place version of :meth:`~Tensor.fmod`
 """)
 
-add_docstr(torch._C.FloatTensorBase.frac,
-           """
+add_docstr_all('frac',
+               """
 frac() -> Tensor
 
 See :func:`torch.frac`
 """)
 
-add_docstr(torch._C.FloatTensorBase.frac_,
-           """
+add_docstr_all('frac_',
+               """
 frac_() -> Tensor
 
 In-place version of :meth:`~Tensor.frac`
 """)
 
-add_docstr(torch._C.FloatTensorBase.gather,
-           """
+add_docstr_all('gather',
+               """
 gather(dim, index) -> Tensor
 
 See :func:`torch.gather`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ge,
-           """
+add_docstr_all('ge',
+               """
 ge(other) -> Tensor
 
 See :func:`torch.ge`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ge_,
-           """
+add_docstr_all('ge_',
+               """
 ge_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.ge`
 """)
 
-add_docstr(torch._C.FloatTensorBase.gels,
-           """
+add_docstr_all('gels',
+               """
 gels(A) -> Tensor
 
 See :func:`torch.gels`
 """)
 
-add_docstr(torch._C.FloatTensorBase.geometric_,
-           """
+add_docstr_all('geometric_',
+               """
 geometric_(p, *, generator=None) -> Tensor
 
 Fills this tensor with elements drawn from the geometric distribution:
@@ -546,50 +567,50 @@
 
 """)
 
-add_docstr(torch._C.FloatTensorBase.geqrf,
-           """
+add_docstr_all('geqrf',
+               """
 geqrf() -> (Tensor, Tensor)
 
 See :func:`torch.geqrf`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ger,
-           """
+add_docstr_all('ger',
+               """
 ger(vec2) -> Tensor
 
 See :func:`torch.ger`
 """)
 
-add_docstr(torch._C.FloatTensorBase.gesv,
-           """
+add_docstr_all('gesv',
+               """
 gesv(A) -> Tensor, Tensor
 
 See :func:`torch.gesv`
 """)
 
-add_docstr(torch._C.FloatTensorBase.gt,
-           """
+add_docstr_all('gt',
+               """
 gt(other) -> Tensor
 
 See :func:`torch.gt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.gt_,
-           """
+add_docstr_all('gt_',
+               """
 gt_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.gt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.histc,
-           """
+add_docstr_all('histc',
+               """
 histc(bins=100, min=0, max=0) -> Tensor
 
 See :func:`torch.histc`
 """)
 
-add_docstr(torch._C.FloatTensorBase.index,
-           """
+add_docstr_all('index',
+               """
 index(m) -> Tensor
 
 Selects elements from this tensor using a binary mask or along a given
@@ -599,8 +620,8 @@
     m (int or ByteTensor or slice): The dimension or mask used to select elements
 """)
 
-add_docstr(torch._C.FloatTensorBase.index_add_,
-           """
+add_docstr_all('index_add_',
+               """
 index_add_(dim, index, tensor) -> Tensor
 
 Accumulate the elements of tensor into the original tensor by adding to the
@@ -624,8 +645,8 @@
     [torch.FloatTensor of size 3x3]
 """)
 
-add_docstr(torch._C.FloatTensorBase.index_copy_,
-           """
+add_docstr_all('index_copy_',
+               """
 index_copy_(dim, index, tensor) -> Tensor
 
 Copies the elements of tensor into the original tensor by selecting the
@@ -649,8 +670,8 @@
     [torch.FloatTensor of size 3x3]
 """)
 
-add_docstr(torch._C.FloatTensorBase.index_fill_,
-           """
+add_docstr_all('index_fill_',
+               """
 index_fill_(dim, index, val) -> Tensor
 
 Fills the elements of the original tensor with value :attr:`val` by selecting
@@ -672,98 +693,98 @@
     [torch.FloatTensor of size 3x3]
 """)
 
-add_docstr(torch._C.FloatTensorBase.index_select,
-           """
+add_docstr_all('index_select',
+               """
 index_select(dim, index) -> Tensor
 
 See :func:`torch.index_select`
 """)
 
-add_docstr(torch._C.FloatTensorBase.inverse,
-           """
+add_docstr_all('inverse',
+               """
 inverse() -> Tensor
 
 See :func:`torch.inverse`
 """)
 
-add_docstr(torch._C.FloatTensorBase.is_contiguous,
-           """
+add_docstr_all('is_contiguous',
+               """
 is_contiguous() -> bool
 
 Returns True if this tensor is contiguous in memory in C order.
 """)
 
-add_docstr(torch._C.FloatTensorBase.is_set_to,
-           """
+add_docstr_all('is_set_to',
+               """
 is_set_to(tensor) -> bool
 
 Returns True if this object refers to the same ``THTensor`` object from the
 Torch C API as the given tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.kthvalue,
-           """
+add_docstr_all('kthvalue',
+               """
 kthvalue(k, dim=None) -> (Tensor, LongTensor)
 
 See :func:`torch.kthvalue`
 """)
 
-add_docstr(torch._C.FloatTensorBase.le,
-           """
+add_docstr_all('le',
+               """
 le(other) -> Tensor
 
 See :func:`torch.le`
 """)
 
-add_docstr(torch._C.FloatTensorBase.le_,
-           """
+add_docstr_all('le_',
+               """
 le_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.le`
 """)
 
-add_docstr(torch._C.FloatTensorBase.lerp,
-           """
+add_docstr_all('lerp',
+               """
 lerp(start, end, weight)
 
 See :func:`torch.lerp`
 """)
 
-add_docstr(torch._C.FloatTensorBase.lerp_,
-           """
+add_docstr_all('lerp_',
+               """
 lerp_(start, end, weight)
 
 In-place version of :meth:`~Tensor.lerp`
 """)
 
-add_docstr(torch._C.FloatTensorBase.log,
-           """
+add_docstr_all('log',
+               """
 log() -> Tensor
 
 See :func:`torch.log`
 """)
 
-add_docstr(torch._C.FloatTensorBase.log1p,
-           """
+add_docstr_all('log1p',
+               """
 log1p() -> Tensor
 
 See :func:`torch.log1p`
 """)
 
-add_docstr(torch._C.FloatTensorBase.log1p_,
-           """
+add_docstr_all('log1p_',
+               """
 log1p_() -> Tensor
 
 In-place version of :meth:`~Tensor.log1p`
 """)
 
-add_docstr(torch._C.FloatTensorBase.log_, """
+add_docstr_all('log_', """
 log_() -> Tensor
 
 In-place version of :meth:`~Tensor.log`
 """)
 
-add_docstr(torch._C.FloatTensorBase.log_normal_, u"""
+add_docstr_all('log_normal_', u"""
 log_normal_(mean=1, std=2, *, generator=None)
 
 Fills this tensor with numbers samples from the log-normal distribution
@@ -776,22 +797,22 @@
     P(x) = \\dfrac{1}{x \\sigma \\sqrt{2\\pi}} e^{-\\dfrac{(\\ln x - \\mu)^2}{2\\sigma^2}}
 """)
 
-add_docstr(torch._C.FloatTensorBase.lt,
-           """
+add_docstr_all('lt',
+               """
 lt(other) -> Tensor
 
 See :func:`torch.lt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.lt_,
-           """
+add_docstr_all('lt_',
+               """
 lt_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.lt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.map_,
-           """
+add_docstr_all('map_',
+               """
 map_(tensor, callable)
 
 Applies :attr:`callable` for each element in this tensor and the given tensor
@@ -803,8 +824,8 @@
     def callable(a, b) -> number
 """)
 
-add_docstr(torch._C.FloatTensorBase.masked_scatter_,
-           """
+add_docstr_all('masked_scatter_',
+               """
 masked_scatter_(mask, source)
 
 Copies elements from :attr:`source` into this tensor at positions where the
@@ -823,8 +844,8 @@ def callable(a, b) -> number
     :attr:`source` tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.masked_fill_,
-           """
+add_docstr_all('masked_fill_',
+               """
 masked_fill_(mask, value)
 
 Fills elements of this tensor with :attr:`value` where :attr:`mask` is one.
@@ -836,85 +857,85 @@ def callable(a, b) -> number
     value (float): The value to fill
 """)
 
-add_docstr(torch._C.FloatTensorBase.masked_select,
-           """
+add_docstr_all('masked_select',
+               """
 masked_select(mask) -> Tensor
 
 See :func:`torch.masked_select`
 """)
 
-add_docstr(torch._C.FloatTensorBase.max,
-           """
+add_docstr_all('max',
+               """
 max(dim=None) -> float or (Tensor, Tensor)
 
 See :func:`torch.max`
 """)
 
-add_docstr(torch._C.FloatTensorBase.mean,
-           """
+add_docstr_all('mean',
+               """
 mean(dim=None) -> float or (Tensor, Tensor)
 
 See :func:`torch.mean`
 """)
 
-add_docstr(torch._C.FloatTensorBase.median,
-           """
+add_docstr_all('median',
+               """
 median(dim=-1, values=None, indices=None) -> (Tensor, LongTensor)
 
 See :func:`torch.median`
 """)
 
-add_docstr(torch._C.FloatTensorBase.min,
-           """
+add_docstr_all('min',
+               """
 min(dim=None) -> float or (Tensor, Tensor)
 
 See :func:`torch.min`
 """)
 
-add_docstr(torch._C.FloatTensorBase.mm,
-           """
+add_docstr_all('mm',
+               """
 mm(mat2) -> Tensor
 
 See :func:`torch.mm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.mode,
-           """
+add_docstr_all('mode',
+               """
 mode(dim=-1, values=None, indices=None) -> (Tensor, LongTensor)
 
 See :func:`torch.mode`
 """)
 
-add_docstr(torch._C.FloatTensorBase.mul,
-           """
+add_docstr_all('mul',
+               """
 mul(value) -> Tensor
 
 See :func:`torch.mul`
 """)
 
-add_docstr(torch._C.FloatTensorBase.mul_,
-           """
+add_docstr_all('mul_',
+               """
 mul_(value)
 
 In-place version of :meth:`~Tensor.mul`
 """)
 
-add_docstr(torch._C.FloatTensorBase.multinomial,
-           """
+add_docstr_all('multinomial',
+               """
 multinomial(num_samples, replacement=False, *, generator=None)
 
 See :func:`torch.multinomial`
 """)
 
-add_docstr(torch._C.FloatTensorBase.mv,
-           """
+add_docstr_all('mv',
+               """
 mv(vec) -> Tensor
 
 See :func:`torch.mv`
 """)
 
-add_docstr(torch._C.FloatTensorBase.narrow,
-           """
+add_docstr_all('narrow',
+               """
 narrow(dimension, start, length) -> Tensor
 
 Returns a new tensor that is a narrowed version of this tensor. The dimension
@@ -939,79 +960,79 @@ def callable(a, b) -> number
     [torch.FloatTensor of size 3x2]
 """)
 
-add_docstr(torch._C.FloatTensorBase.ndimension,
-           """
+add_docstr_all('ndimension',
+               """
 ndimension() -> int
 
 Alias for :meth:`~Tensor.dim()`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ne,
-           """
+add_docstr_all('ne',
+               """
 ne(other) -> Tensor
 
 See :func:`torch.ne`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ne_,
-           """
+add_docstr_all('ne_',
+               """
 ne_(other) -> Tensor
 
 In-place version of :meth:`~Tensor.ne`
 """)
 
-add_docstr(torch._C.FloatTensorBase.neg,
-           """
+add_docstr_all('neg',
+               """
 neg() -> Tensor
 
 See :func:`torch.neg`
 """)
 
-add_docstr(torch._C.FloatTensorBase.neg_,
-           """
+add_docstr_all('neg_',
+               """
 neg_() -> Tensor
 
 In-place version of :meth:`~Tensor.neg`
 """)
 
-add_docstr(torch._C.FloatTensorBase.nelement,
-           """
+add_docstr_all('nelement',
+               """
 nelement() -> int
 
 Alias for :meth:`~Tensor.numel`
 """)
 
-add_docstr(torch._C.FloatTensorBase.nonzero,
-           """
+add_docstr_all('nonzero',
+               """
 nonzero() -> LongTensor
 
 See :func:`torch.nonzero`
 """)
 
-add_docstr(torch._C.FloatTensorBase.norm,
-           """
+add_docstr_all('norm',
+               """
 norm(p=2) -> float
 
 See :func:`torch.norm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.normal_,
-           """
+add_docstr_all('normal_',
+               """
 normal_(mean=0, std=1, *, generator=None)
 
 Fills this tensor with elements samples from the normal distribution
 parameterized by :attr:`mean` and :attr:`std`.
 """)
 
-add_docstr(torch._C.FloatTensorBase.numel,
-           """
+add_docstr_all('numel',
+               """
 numel() -> int
 
 See :func:`torch.numel`
 """)
 
-add_docstr(torch._C.FloatTensorBase.numpy,
-           """
+add_docstr_all('numpy',
+               """
 numpy() -> ndarray
 
 Returns this tensor as a NumPy :class:`ndarray`. This tensor and the returned
@@ -1019,78 +1040,78 @@ def callable(a, b) -> number
 be reflected in the :class:`ndarray` and vice versa.
 """)
 
-add_docstr(torch._C.FloatTensorBase.orgqr,
-           """
+add_docstr_all('orgqr',
+               """
 orgqr(input2) -> Tensor
 
 See :func:`torch.orgqr`
 """)
 
-add_docstr(torch._C.FloatTensorBase.ormqr,
-           """
+add_docstr_all('ormqr',
+               """
 ormqr(input2, input3, left=True, transpose=False) -> Tensor
 
 See :func:`torch.ormqr`
 """)
 
-add_docstr(torch._C.FloatTensorBase.potrf,
-           """
+add_docstr_all('potrf',
+               """
 potrf(upper=True) -> Tensor
 
 See :func:`torch.potrf`
 """)
 
-add_docstr(torch._C.FloatTensorBase.potri,
-           """
+add_docstr_all('potri',
+               """
 potri(upper=True) -> Tensor
 
 See :func:`torch.potri`
 """)
 
-add_docstr(torch._C.FloatTensorBase.potrs,
-           """
+add_docstr_all('potrs',
+               """
 potrs(input2, upper=True) -> Tensor
 
 See :func:`torch.potrs`
 """)
 
-add_docstr(torch._C.FloatTensorBase.pow,
-           """
+add_docstr_all('pow',
+               """
 pow(exponent)
 
 See :func:`torch.pow`
 """)
 
-add_docstr(torch._C.FloatTensorBase.pow_,
-           """
+add_docstr_all('pow_',
+               """
 pow_(exponent)
 
 In-place version of :meth:`~Tensor.pow`
 """)
 
-add_docstr(torch._C.FloatTensorBase.prod,
-           """
+add_docstr_all('prod',
+               """
 prod() -> float
 
 See :func:`torch.prod`
 """)
 
-add_docstr(torch._C.FloatTensorBase.pstrf,
-           """
+add_docstr_all('pstrf',
+               """
 pstrf(upper=True, tol=-1) -> (Tensor, IntTensor)
 
 See :func:`torch.pstrf`
 """)
 
-add_docstr(torch._C.FloatTensorBase.qr,
-           """
+add_docstr_all('qr',
+               """
 qr() -> (Tensor, Tensor)
 
 See :func:`torch.qr`
 """)
 
-add_docstr(torch._C.FloatTensorBase.random_,
-           """
+add_docstr_all('random_',
+               """
 random_(from=0, to=None, *, generator=None)
 
 Fills this tensor with numbers sampled from the uniform distribution or
@@ -1098,50 +1119,50 @@ def callable(a, b) -> number
 values are only bounded by this tensor's data type.
 """)
 
-add_docstr(torch._C.FloatTensorBase.reciprocal,
-           """
+add_docstr_all('reciprocal',
+               """
 reciprocal() -> Tensor
 
 See :func:`torch.reciprocal`
 """)
 
-add_docstr(torch._C.FloatTensorBase.reciprocal_,
-           """
+add_docstr_all('reciprocal_',
+               """
 reciprocal_() -> Tensor
 
 In-place version of :meth:`~Tensor.reciprocal`
 """)
 
-add_docstr(torch._C.FloatTensorBase.remainder,
-           """
+add_docstr_all('remainder',
+               """
 remainder(divisor) -> Tensor
 
 See :func:`torch.remainder`
 """)
 
-add_docstr(torch._C.FloatTensorBase.remainder_,
-           """
+add_docstr_all('remainder_',
+               """
 remainder_(divisor) -> Tensor
 
 In-place version of :meth:`~Tensor.remainder`
 """)
 
-add_docstr(torch._C.FloatTensorBase.renorm,
-           """
+add_docstr_all('renorm',
+               """
 renorm(p, dim, maxnorm) -> Tensor
 
 See :func:`torch.renorm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.renorm_,
-           """
+add_docstr_all('renorm_',
+               """
 renorm_(p, dim, maxnorm) -> Tensor
 
 In-place version of :meth:`~Tensor.renorm`
 """)
 
-add_docstr(torch._C.FloatTensorBase.resize_,
-           """
+add_docstr_all('resize_',
+               """
 resize_(*sizes)
 
 Resizes this tensor to the specified size. If the number of elements is
@@ -1162,8 +1183,8 @@ def callable(a, b) -> number
     [torch.FloatTensor of size 2x2]
 """)
 
-add_docstr(torch._C.FloatTensorBase.resize_as_,
-           """
+add_docstr_all('resize_as_',
+               """
 resize_as_(tensor)
 
 Resizes the current tensor to be the same size as the specified tensor. This is
@@ -1172,36 +1193,36 @@ def callable(a, b) -> number
     self.resize_(tensor.size())
 """)
 
-add_docstr(torch._C.FloatTensorBase.round,
-           """
+add_docstr_all('round',
+               """
 round() -> Tensor
 
 See :func:`torch.round`
 """)
 
-add_docstr(torch._C.FloatTensorBase.round_,
-           """
+add_docstr_all('round_',
+               """
 round_() -> Tensor
 
 In-place version of :meth:`~Tensor.round`
 """)
 
-add_docstr(torch._C.FloatTensorBase.rsqrt,
-           """
+add_docstr_all('rsqrt',
+               """
 rsqrt() -> Tensor
 
 See :func:`torch.rsqrt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.rsqrt_,
-           """
+add_docstr_all('rsqrt_',
+               """
 rsqrt_() -> Tensor
 
 In-place version of :meth:`~Tensor.rsqrt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.scatter_,
-           """
+add_docstr_all('scatter_',
+               """
 scatter_(dim, index, src) -> Tensor
 
 Writes all values from the Tensor :attr:`src` into self at the indices specified
@@ -1242,8 +1263,8 @@ def callable(a, b) -> number
 
 """)
 
-add_docstr(torch._C.FloatTensorBase.select,
-           """
+add_docstr_all('select',
+               """
 select(dim, index) -> Tensor or number
 
 Slices the tensor along the selected dimension at the given index. If this
@@ -1261,8 +1282,8 @@ def callable(a, b) -> number
     to ``tensor[:,:,index]``.
 """)
 
-add_docstr(torch._C.FloatTensorBase.set_,
-           """
+add_docstr_all('set_',
+               """
 set_(source=None, storage_offset=0, size=None, stride=None)
 
 Sets the underlying storage, size, and strides. If :attr:`source` is a tensor,
@@ -1280,64 +1301,64 @@ def callable(a, b) -> number
     stride (tuple): The desired stride. Defaults to C-contiguous strides.
 """)
 
-add_docstr(torch._C.FloatTensorBase.sigmoid,
-           """
+add_docstr_all('sigmoid',
+               """
 sigmoid() -> Tensor
 
 See :func:`torch.sigmoid`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sigmoid_,
-           """
+add_docstr_all('sigmoid_',
+               """
 sigmoid_() -> Tensor
 
 In-place version of :meth:`~Tensor.sigmoid`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sign,
-           """
+add_docstr_all('sign',
+               """
 sign() -> Tensor
 
 See :func:`torch.sign`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sign_,
-           """
+add_docstr_all('sign_',
+               """
 sign_() -> Tensor
 
 In-place version of :meth:`~Tensor.sign`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sin,
-           """
+add_docstr_all('sin',
+               """
 sin() -> Tensor
 
 See :func:`torch.sin`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sin_,
-           """
+add_docstr_all('sin_',
+               """
 sin_() -> Tensor
 
 In-place version of :meth:`~Tensor.sin`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sinh,
-           """
+add_docstr_all('sinh',
+               """
 sinh() -> Tensor
 
 See :func:`torch.sinh`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sinh_,
-           """
+add_docstr_all('sinh_',
+               """
 sinh_() -> Tensor
 
 In-place version of :meth:`~Tensor.sinh`
 """)
 
-add_docstr(torch._C.FloatTensorBase.size,
-           """
+add_docstr_all('size',
+               """
 size() -> torch.Size
 
 Returns the size of the tensor. The returned value is a subclass of
@@ -1348,57 +1369,57 @@ def callable(a, b) -> number
     torch.Size([3, 4, 5])
 """)
 
-add_docstr(torch._C.FloatTensorBase.sort,
-           """
+add_docstr_all('sort',
+               """
 sort(dim=None, descending=False) -> (Tensor, LongTensor)
 
 See :func:`torch.sort`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sqrt,
-           """
+add_docstr_all('sqrt',
+               """
 sqrt() -> Tensor
 
 See :func:`torch.sqrt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sqrt_,
-           """
+add_docstr_all('sqrt_',
+               """
 sqrt_() -> Tensor
 
 In-place version of :meth:`~Tensor.sqrt`
 """)
 
-add_docstr(torch._C.FloatTensorBase.squeeze,
-           """
+add_docstr_all('squeeze',
+               """
 squeeze(dim=None)
 
 See :func:`torch.squeeze`
 """)
 
-add_docstr(torch._C.FloatTensorBase.squeeze_,
-           """
+add_docstr_all('squeeze_',
+               """
 squeeze_(dim=None)
 
 In-place version of :meth:`~Tensor.squeeze`
 """)
 
-add_docstr(torch._C.FloatTensorBase.std,
-           """
+add_docstr_all('std',
+               """
 std() -> float
 
 See :func:`torch.std`
 """)
 
-add_docstr(torch._C.FloatTensorBase.storage,
-           """
+add_docstr_all('storage',
+               """
 storage() -> torch.Storage
 
 Returns the underlying storage
 """)
 
-add_docstr(torch._C.FloatTensorBase.storage_offset,
-           """
+add_docstr_all('storage_offset',
+               """
 storage_offset() -> int
 
 Returns this tensor's offset in the underlying storage in terms of number of
@@ -1412,15 +1433,15 @@ def callable(a, b) -> number
     3
 """)
 
-add_docstr(torch._C.FloatTensorBase.stride,
-           """
+add_docstr_all('stride',
+               """
 stride() -> tuple
 
 Returns the stride of the tensor.
 """)
 
-add_docstr(torch._C.FloatTensorBase.sub,
-           """
+add_docstr_all('sub',
+               """
 sub(value, other) -> Tensor
 
 Subtracts a scalar or tensor from this tensor. If both :attr:`value` and
@@ -1432,155 +1453,155 @@ def callable(a, b) -> number
 
 """)
 
-add_docstr(torch._C.FloatTensorBase.sub_,
-           """
+add_docstr_all('sub_',
+               """
 sub_(x) -> Tensor
 
 In-place version of :meth:`~Tensor.sub`
 """)
 
-add_docstr(torch._C.FloatTensorBase.sum,
-           """
+add_docstr_all('sum',
+               """
 sum(dim=None) -> float
 
 See :func:`torch.sum`
 """)
 
-add_docstr(torch._C.FloatTensorBase.svd,
-           """
+add_docstr_all('svd',
+               """
 svd(some=True) -> (Tensor, Tensor, Tensor)
 
 See :func:`torch.svd`
 """)
 
-add_docstr(torch._C.FloatTensorBase.symeig,
-           """
+add_docstr_all('symeig',
+               """
 symeig(eigenvectors=False, upper=True) -> (Tensor, Tensor)
 
 See :func:`torch.symeig`
 """)
 
-add_docstr(torch._C.FloatTensorBase.t,
-           """
+add_docstr_all('t',
+               """
 t() -> Tensor
 
 See :func:`torch.t`
 """)
 
-add_docstr(torch._C.FloatTensorBase.t_,
-           """
+add_docstr_all('t_',
+               """
 t_() -> Tensor
 
 In-place version of :meth:`~Tensor.t`
 """)
 
-add_docstr(torch._C.FloatTensorBase.tan,
-           """
+add_docstr_all('tan',
+               """
 tan() -> Tensor
 
 See :func:`torch.tan`
 """)
 
-add_docstr(torch._C.FloatTensorBase.tan_,
-           """
+add_docstr_all('tan_',
+               """
 tan_() -> Tensor
 
 In-place version of :meth:`~Tensor.tan`
 """)
 
-add_docstr(torch._C.FloatTensorBase.tanh,
-           """
+add_docstr_all('tanh',
+               """
 tanh() -> Tensor
 
 See :func:`torch.tanh`
 """)
 
-add_docstr(torch._C.FloatTensorBase.tanh_,
-           """
+add_docstr_all('tanh_',
+               """
 tanh_() -> Tensor
 
 In-place version of :meth:`~Tensor.tanh`
 """)
 
-add_docstr(torch._C.FloatTensorBase.topk,
-           """
+add_docstr_all('topk',
+               """
 topk(k, dim=None, largest=True, sorted=True) -> (Tensor, LongTensor)
 
 See :func:`torch.topk`
 """)
 
-add_docstr(torch._C.FloatTensorBase.trace,
-           """
+add_docstr_all('trace',
+               """
 trace() -> float
 
 See :func:`torch.trace`
 """)
 
-add_docstr(torch._C.FloatTensorBase.transpose,
-           """
+add_docstr_all('transpose',
+               """
 transpose(dim0, dim1) -> Tensor
 
 See :func:`torch.transpose`
 """)
 
-add_docstr(torch._C.FloatTensorBase.transpose_,
-           """
+add_docstr_all('transpose_',
+               """
 transpose_(dim0, dim1) -> Tensor
 
 In-place version of :meth:`~Tensor.transpose`
 """)
 
-add_docstr(torch._C.FloatTensorBase.tril,
-           """
+add_docstr_all('tril',
+               """
 tril(k=0) -> Tensor
 
 See :func:`torch.tril`
 """)
 
-add_docstr(torch._C.FloatTensorBase.tril_,
-           """
+add_docstr_all('tril_',
+               """
 tril_(k=0) -> Tensor
 
 In-place version of :meth:`~Tensor.tril`
 """)
 
-add_docstr(torch._C.FloatTensorBase.triu,
-           """
+add_docstr_all('triu',
+               """
 triu(k=0) -> Tensor
 
 See :func:`torch.triu`
 """)
 
-add_docstr(torch._C.FloatTensorBase.triu_,
-           """
+add_docstr_all('triu_',
+               """
 triu_(k=0) -> Tensor
 
 In-place version of :meth:`~Tensor.triu`
 """)
 
-add_docstr(torch._C.FloatTensorBase.trtrs,
-           """
+add_docstr_all('trtrs',
+               """
 trtrs(A, upper=True, transpose=False, unitriangular=False) -> (Tensor, Tensor)
 
 See :func:`torch.trtrs`
 """)
 
-add_docstr(torch._C.FloatTensorBase.trunc,
-           """
+add_docstr_all('trunc',
+               """
 trunc() -> Tensor
 
 See :func:`torch.trunc`
 """)
 
-add_docstr(torch._C.FloatTensorBase.trunc_,
-           """
+add_docstr_all('trunc_',
+               """
 trunc_() -> Tensor
 
 In-place version of :meth:`~Tensor.trunc`
 """)
 
-add_docstr(torch._C.FloatTensorBase.unfold,
-           """
+add_docstr_all('unfold',
+               """
 unfold(dim, size, step) -> Tensor
 
 Returns a tensor which contains all slices of size :attr:`size` in
@@ -1631,8 +1652,8 @@ def callable(a, b) -> number
 
 """)
 
-add_docstr(torch._C.FloatTensorBase.uniform_,
-           """
+add_docstr_all('uniform_',
+               """
 uniform_(from=0, to=1) -> Tensor
 
 Fills this tensor with numbers sampled from the uniform distribution:
@@ -1642,29 +1663,29 @@ def callable(a, b) -> number
     P(x) = \dfrac{1}{to - from}
 """)
 
-add_docstr(torch._C.FloatTensorBase.unsqueeze,
-           """
+add_docstr_all('unsqueeze',
+               """
 unsqueeze(dim)
 
 See :func:`torch.unsqueeze`
 """)
 
-add_docstr(torch._C.FloatTensorBase.unsqueeze_,
-           """
+add_docstr_all('unsqueeze_',
+               """
 unsqueeze_(dim)
 
 In-place version of :meth:`~Tensor.unsqueeze`
 """)
 
-add_docstr(torch._C.FloatTensorBase.var,
-           """
+add_docstr_all('var',
+               """
 var() -> float
 
 See :func:`torch.var`
 """)
 
-add_docstr(torch._C.FloatTensorBase.view,
-           """
+add_docstr_all('view',
+               """
 view(*args) -> Tensor
 
 Returns a new tensor with the same data but different size.
@@ -1688,8 +1709,8 @@ def callable(a, b) -> number
     torch.Size([2, 8])
 """)
 
-add_docstr(torch._C.FloatTensorBase.expand,
-           """
+add_docstr_all('expand',
+               """
 expand(tensor, sizes) -> Tensor
 
 Returns a new view of the tensor with singleton dimensions expanded
@@ -1718,8 +1739,8 @@ def callable(a, b) -> number
     [torch.FloatTensor of size 3x4]
 """)
 
-add_docstr(torch._C.FloatTensorBase.zero_,
-           """
+add_docstr_all('zero_',
+               """
 zero_()
 
 Fills this tensor with zeros.


Test patch: