[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-pytorch-pytorch-.claude-skills-docstring":3},{"error":4,"detail":5,"metadata":23,"markdownContent":24,"rawMarkdown":20},false,{"repo_full_name":6,"owner":7,"repo_name":7,"repo_forks":8,"skill_path":9,"repo_stars":10,"name":11,"category_id":12,"description":13,"file_tree":14,"skill_md_content":20,"skill_id":21,"skill_key":22},"pytorch/pytorch","pytorch",27276,".claude/skills/docstring",98502,"docstring",12,"Write docstrings for PyTorch functions and methods following PyTorch conventions. Use when writing or updating docstrings in PyTorch code.",[15],{"name":16,"path":17,"size":18,"type":19},"SKILL.md",".claude/skills/docstring/SKILL.md",10219,"file","---\nname: docstring\ndescription: Write docstrings for PyTorch functions and methods following PyTorch conventions. Use when writing or updating docstrings in PyTorch code.\n---\n\n# PyTorch Docstring Writing Guide\n\nThis skill describes how to write docstrings for functions and methods in the PyTorch project, following the conventions in `torch/_tensor_docs.py` and `torch/nn/functional.py`.\n\n## General Principles\n\n- Use **raw strings** (`r\"\"\"...\"\"\"`) for all docstrings to avoid issues with LaTeX/math backslashes\n- Follow **Sphinx/reStructuredText** (reST) format for documentation\n- Be **concise but complete** - include all essential information\n- Always include **examples** when possible\n- Use **cross-references** to related functions/classes\n\n## Docstring Structure\n\n### 1. Function Signature (First Line)\n\nStart with the function signature showing all parameters:\n\n```python\nr\"\"\"function_name(param1, param2, *, kwarg1=default1, kwarg2=default2) -> ReturnType\n```\n\n**Notes:**\n- Include the function name\n- Show positional and keyword-only arguments (use `*` separator)\n- Include default values\n- Show return type annotation\n- This line should NOT end with a period\n\n### 2. Brief Description\n\nProvide a one-line description of what the function does:\n\n```python\nr\"\"\"conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor\n\nApplies a 2D convolution over an input image composed of several input\nplanes.\n```\n\n### 3. Mathematical Formulas (if applicable)\n\nUse Sphinx math directives for mathematical expressions:\n\n```python\n.. math::\n    \\text{Softmax}(x_{i}) = \\frac{\\exp(x_i)}{\\sum_j \\exp(x_j)}\n```\n\nOr inline math: `:math:\\`x^2\\``\n\n### 4. Cross-References\n\nLink to related classes and functions using Sphinx roles:\n\n- `:class:\\`~torch.nn.ModuleName\\`` - Link to a class\n- `:func:\\`torch.function_name\\`` - Link to a function\n- `:meth:\\`~Tensor.method_name\\`` - Link to a method\n- `:attr:\\`attribute_name\\`` - Reference an attribute\n- The `~` prefix shows only the last component (e.g., `Conv2d` instead of `torch.nn.Conv2d`)\n\n**Example:**\n```python\nSee :class:`~torch.nn.Conv2d` for details and output shape.\n```\n\n### 5. Notes and Warnings\n\nUse admonitions for important information:\n\n```python\n.. note::\n    This function doesn't work directly with NLLLoss,\n    which expects the Log to be computed between the Softmax and itself.\n    Use log_softmax instead (it's faster and has better numerical properties).\n\n.. warning::\n    :func:`new_tensor` always copies :attr:`data`. If you have a Tensor\n    ``data`` and want to avoid a copy, use :func:`torch.Tensor.requires_grad_`\n    or :func:`torch.Tensor.detach`.\n```\n\n### 6. Args Section\n\nDocument all parameters with type annotations and descriptions:\n\n```python\nArgs:\n    input (Tensor): input tensor of shape :math:`(\\text{minibatch} , \\text{in\\_channels} , iH , iW)`\n    weight (Tensor): filters of shape :math:`(\\text{out\\_channels} , kH , kW)`\n    bias (Tensor, optional): optional bias tensor of shape :math:`(\\text{out\\_channels})`. Default: ``None``\n    stride (int or tuple): the stride of the convolving kernel. Can be a single number or a\n      tuple `(sH, sW)`. Default: 1\n```\n\n**Formatting rules:**\n- Parameter name in **lowercase**\n- Type in parentheses: `(Type)`, `(Type, optional)` for optional parameters\n- Description follows the type\n- For optional parameters, include \"Default: ``value``\" at the end\n- Use double backticks for inline code: ``` ``None`` ```\n- Indent continuation lines by 2 spaces\n\n### 7. Keyword Args Section (if applicable)\n\nSometimes keyword arguments are documented separately:\n\n```python\nKeyword args:\n    dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.\n        Default: if None, same :class:`torch.dtype` as this tensor.\n    device (:class:`torch.device`, optional): the desired device of returned tensor.\n        Default: if None, same :class:`torch.device` as this tensor.\n    requires_grad (bool, optional): If autograd should record operations on the\n        returned tensor. Default: ``False``.\n```\n\n### 8. Returns Section (if needed)\n\nDocument the return value:\n\n```python\nReturns:\n    Tensor: Sampled tensor of same shape as `logits` from the Gumbel-Softmax distribution.\n        If ``hard=True``, the returned samples will be one-hot, otherwise they will\n        be probability distributions that sum to 1 across `dim`.\n```\n\nOr simply include it in the function signature line if obvious from context.\n\n### 9. Examples Section\n\nAlways include examples when possible:\n\n```python\nExamples::\n\n    >>> inputs = torch.randn(33, 16, 30)\n    >>> filters = torch.randn(20, 16, 5)\n    >>> F.conv1d(inputs, filters)\n\n    >>> # With square kernels and equal stride\n    >>> filters = torch.randn(8, 4, 3, 3)\n    >>> inputs = torch.randn(1, 4, 5, 5)\n    >>> F.conv2d(inputs, filters, padding=1)\n```\n\n**Formatting rules:**\n- Use `Examples::` with double colon\n- Use `>>>` prompt for Python code\n- Include comments with `#` when helpful\n- Show actual output when it helps understanding (indent without `>>>`)\n\n### 10. External References\n\nLink to papers or external documentation:\n\n```python\n.. _Link Name:\n    https://arxiv.org/abs/1611.00712\n```\n\nReference them in text: ```See `Link Name`_```\n\n## Method Types\n\n### Native Python Functions\n\nFor regular Python functions, use a standard docstring:\n\n```python\ndef relu(input: Tensor, inplace: bool = False) -> Tensor:\n    r\"\"\"relu(input, inplace=False) -> Tensor\n\n    Applies the rectified linear unit function element-wise. See\n    :class:`~torch.nn.ReLU` for more details.\n    \"\"\"\n    # implementation\n```\n\n### C-Bound Functions (using add_docstr)\n\nFor C-bound functions, use `_add_docstr`:\n\n```python\nconv1d = _add_docstr(\n    torch.conv1d,\n    r\"\"\"\nconv1d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor\n\nApplies a 1D convolution over an input signal composed of several input\nplanes.\n\nSee :class:`~torch.nn.Conv1d` for details and output shape.\n\nArgs:\n    input: input tensor of shape :math:`(\\text{minibatch} , \\text{in\\_channels} , iW)`\n    weight: filters of shape :math:`(\\text{out\\_channels} , kW)`\n    ...\n\"\"\",\n)\n```\n\n### In-Place Variants\n\nFor in-place operations (ending with `_`), reference the original:\n\n```python\nadd_docstr_all(\n    \"abs_\",\n    r\"\"\"\nabs_() -> Tensor\n\nIn-place version of :meth:`~Tensor.abs`\n\"\"\",\n)\n```\n\n### Alias Functions\n\nFor aliases, simply reference the original:\n\n```python\nadd_docstr_all(\n    \"absolute\",\n    r\"\"\"\nabsolute() -> Tensor\n\nAlias for :func:`abs`\n\"\"\",\n)\n```\n\n## Common Patterns\n\n### Shape Documentation\n\nUse LaTeX math notation for tensor shapes:\n\n```python\n:math:`(\\text{minibatch} , \\text{in\\_channels} , iH , iW)`\n```\n\n### Reusable Argument Definitions\n\nFor commonly used arguments, define them once and reuse:\n\n```python\ncommon_args = parse_kwargs(\n    \"\"\"\n    dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.\n        Default: if None, same as this tensor.\n\"\"\"\n)\n\n# Then use with .format():\nr\"\"\"\n...\n\nKeyword args:\n    {dtype}\n    {device}\n\"\"\".format(**common_args)\n```\n\n### Template Insertion\n\nInsert reproducibility notes or other common text:\n\n```python\nr\"\"\"\n{tf32_note}\n\n{cudnn_reproducibility_note}\n\"\"\".format(**reproducibility_notes, **tf32_notes)\n```\n\n## Complete Example\n\nHere's a complete example showing all elements:\n\n```python\ndef gumbel_softmax(\n    logits: Tensor,\n    tau: float = 1,\n    hard: bool = False,\n    eps: float = 1e-10,\n    dim: int = -1,\n) -> Tensor:\n    r\"\"\"\n    Sample from the Gumbel-Softmax distribution and optionally discretize.\n\n    Args:\n        logits (Tensor): `[..., num_features]` unnormalized log probabilities\n        tau (float): non-negative scalar temperature\n        hard (bool): if ``True``, the returned samples will be discretized as one-hot vectors,\n              but will be differentiated as if it is the soft sample in autograd. Default: ``False``\n        dim (int): A dimension along which softmax will be computed. Default: -1\n\n    Returns:\n        Tensor: Sampled tensor of same shape as `logits` from the Gumbel-Softmax distribution.\n            If ``hard=True``, the returned samples will be one-hot, otherwise they will\n            be probability distributions that sum to 1 across `dim`.\n\n    .. note::\n        This function is here for legacy reasons, may be removed from nn.Functional in the future.\n\n    Examples::\n        >>> logits = torch.randn(20, 32)\n        >>> # Sample soft categorical using reparametrization trick:\n        >>> F.gumbel_softmax(logits, tau=1, hard=False)\n        >>> # Sample hard categorical using \"Straight-through\" trick:\n        >>> F.gumbel_softmax(logits, tau=1, hard=True)\n\n    .. _Link 1:\n        https://arxiv.org/abs/1611.00712\n    \"\"\"\n    # implementation\n```\n\n## Quick Checklist\n\nWhen writing a PyTorch docstring, ensure:\n\n- [ ] Use raw string (`r\"\"\"`)\n- [ ] Include function signature on first line\n- [ ] Provide brief description\n- [ ] Document all parameters in Args section with types\n- [ ] Include default values for optional parameters\n- [ ] Use Sphinx cross-references (`:func:`, `:class:`, `:meth:`)\n- [ ] Add mathematical formulas if applicable\n- [ ] Include at least one example in Examples section\n- [ ] Add warnings/notes for important caveats\n- [ ] Link to related module class with `:class:`\n- [ ] Use proper math notation for tensor shapes\n- [ ] Follow consistent formatting and indentation\n\n## Common Sphinx Roles Reference\n\n- `:class:\\`~torch.nn.Module\\`` - Class reference\n- `:func:\\`torch.function\\`` - Function reference\n- `:meth:\\`~Tensor.method\\`` - Method reference\n- `:attr:\\`attribute\\`` - Attribute reference\n- `:math:\\`equation\\`` - Inline math\n- `:ref:\\`label\\`` - Internal reference\n- ``` ``code`` ``` - Inline code (use double backticks)\n\n## Additional Notes\n\n- **Indentation**: Use 4 spaces for code, 2 spaces for continuation of parameter descriptions\n- **Line length**: Try to keep lines under 100 characters when possible\n- **Periods**: End sentences with periods, but not the signature line\n- **Backticks**: Use double backticks for code: ``` ``True`` ``None`` ``False`` ```\n- **Types**: Common types are `Tensor`, `int`, `float`, `bool`, `str`, `tuple`, `list`, etc.\n","f170abce-43b8-5316-b55c-98ae2d76d174","pytorch-pytorch-.claude-skills-docstring",{"name":11,"description":13},"\u003Ch1>PyTorch Docstring Writing Guide\u003C/h1>\n\u003Cp>This skill describes how to write docstrings for functions and methods in the PyTorch project, following the conventions in \u003Ccode>torch/_tensor_docs.py\u003C/code> and \u003Ccode>torch/nn/functional.py\u003C/code>.\u003C/p>\n\u003Ch2>General Principles\u003C/h2>\n\u003Cul>\n\u003Cli>Use \u003Cstrong>raw strings\u003C/strong> (\u003Ccode>r&quot;&quot;&quot;...&quot;&quot;&quot;\u003C/code>) for all docstrings to avoid issues with LaTeX/math backslashes\u003C/li>\n\u003Cli>Follow \u003Cstrong>Sphinx/reStructuredText\u003C/strong> (reST) format for documentation\u003C/li>\n\u003Cli>Be \u003Cstrong>concise but complete\u003C/strong> - include all essential information\u003C/li>\n\u003Cli>Always include \u003Cstrong>examples\u003C/strong> when possible\u003C/li>\n\u003Cli>Use \u003Cstrong>cross-references\u003C/strong> to related functions/classes\u003C/li>\n\u003C/ul>\n\u003Ch2>Docstring Structure\u003C/h2>\n\u003Ch3>1. Function Signature (First Line)\u003C/h3>\n\u003Cp>Start with the function signature showing all parameters:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;function_name(param1, param2, *, kwarg1=default1, kwarg2=default2) -&gt; ReturnType\u003C/span>\u003C/code>\u003C/pre>\u003C/div>\u003Cp>\u003Cstrong>Notes:\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Include the function name\u003C/li>\n\u003Cli>Show positional and keyword-only arguments (use \u003Ccode>*\u003C/code> separator)\u003C/li>\n\u003Cli>Include default values\u003C/li>\n\u003Cli>Show return type annotation\u003C/li>\n\u003Cli>This line should NOT end with a period\u003C/li>\n\u003C/ul>\n\u003Ch3>2. Brief Description\u003C/h3>\n\u003Cp>Provide a one-line description of what the function does:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -&gt; Tensor\n\nApplies a 2D convolution over an input image composed of several input\nplanes.\u003C/span>\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>3. Mathematical Formulas (if applicable)\u003C/h3>\n\u003Cp>Use Sphinx math directives for mathematical expressions:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">.. math::\n    \\text{Softmax}(x_{i}) = \\frac{\\exp(x_i)}{\\sum_j \\exp(x_j)}\u003C/code>\u003C/pre>\u003C/div>\u003Cp>Or inline math: \u003Ccode>:math:\\\u003C/code>x^2``\u003C/p>\n\u003Ch3>4. Cross-References\u003C/h3>\n\u003Cp>Link to related classes and functions using Sphinx roles:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Ccode>:class:\\\u003C/code>~torch.nn.ModuleName`` - Link to a class\u003C/li>\n\u003Cli>\u003Ccode>:func:\\\u003C/code>torch.function_name`` - Link to a function\u003C/li>\n\u003Cli>\u003Ccode>:meth:\\\u003C/code>~Tensor.method_name`` - Link to a method\u003C/li>\n\u003Cli>\u003Ccode>:attr:\\\u003C/code>attribute_name`` - Reference an attribute\u003C/li>\n\u003Cli>The \u003Ccode>~\u003C/code> prefix shows only the last component (e.g., \u003Ccode>Conv2d\u003C/code> instead of \u003Ccode>torch.nn.Conv2d\u003C/code>)\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>Example:\u003C/strong>\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">See :\u003Cspan class=\"hljs-keyword\">class\u003C/span>:`~torch.nn.Conv2d` \u003Cspan class=\"hljs-keyword\">for\u003C/span> details \u003Cspan class=\"hljs-keyword\">and\u003C/span> output shape.\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>5. Notes and Warnings\u003C/h3>\n\u003Cp>Use admonitions for important information:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">.. note::\n    This function doesn\u003Cspan class=\"hljs-string\">&#x27;t work directly with NLLLoss,\n    which expects the Log to be computed between the Softmax and itself.\n    Use log_softmax instead (it&#x27;\u003C/span>s faster \u003Cspan class=\"hljs-keyword\">and\u003C/span> has better numerical properties).\n\n.. warning::\n    :func:`new_tensor` always copies :attr:`data`. If you have a Tensor\n    ``data`` \u003Cspan class=\"hljs-keyword\">and\u003C/span> want to avoid a copy, use :func:`torch.Tensor.requires_grad_`\n    \u003Cspan class=\"hljs-keyword\">or\u003C/span> :func:`torch.Tensor.detach`.\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>6. Args Section\u003C/h3>\n\u003Cp>Document all parameters with type annotations and descriptions:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">Args:\n    \u003Cspan class=\"hljs-built_in\">input\u003C/span> (Tensor): \u003Cspan class=\"hljs-built_in\">input\u003C/span> tensor of shape :math:`(\\text{minibatch} , \\text{\u003Cspan class=\"hljs-keyword\">in\u003C/span>\\_channels} , iH , iW)`\n    weight (Tensor): filters of shape :math:`(\\text{out\\_channels} , kH , kW)`\n    bias (Tensor, optional): optional bias tensor of shape :math:`(\\text{out\\_channels})`. Default: ``\u003Cspan class=\"hljs-literal\">None\u003C/span>``\n    stride (\u003Cspan class=\"hljs-built_in\">int\u003C/span> \u003Cspan class=\"hljs-keyword\">or\u003C/span> \u003Cspan class=\"hljs-built_in\">tuple\u003C/span>): the stride of the convolving kernel. Can be a single number \u003Cspan class=\"hljs-keyword\">or\u003C/span> a\n      \u003Cspan class=\"hljs-built_in\">tuple\u003C/span> `(sH, sW)`. Default: \u003Cspan class=\"hljs-number\">1\u003C/span>\u003C/code>\u003C/pre>\u003C/div>\u003Cp>\u003Cstrong>Formatting rules:\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Parameter name in \u003Cstrong>lowercase\u003C/strong>\u003C/li>\n\u003Cli>Type in parentheses: \u003Ccode>(Type)\u003C/code>, \u003Ccode>(Type, optional)\u003C/code> for optional parameters\u003C/li>\n\u003Cli>Description follows the type\u003C/li>\n\u003Cli>For optional parameters, include &quot;Default: \u003Ccode>value\u003C/code>&quot; at the end\u003C/li>\n\u003Cli>Use double backticks for inline code: \u003Ccode>``None``\u003C/code>\u003C/li>\n\u003Cli>Indent continuation lines by 2 spaces\u003C/li>\n\u003C/ul>\n\u003Ch3>7. Keyword Args Section (if applicable)\u003C/h3>\n\u003Cp>Sometimes keyword arguments are documented separately:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">Keyword args:\n    dtype (:\u003Cspan class=\"hljs-keyword\">class\u003C/span>:`torch.dtype`, optional): the desired \u003Cspan class=\"hljs-built_in\">type\u003C/span> of returned tensor.\n        Default: \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-literal\">None\u003C/span>, same :\u003Cspan class=\"hljs-keyword\">class\u003C/span>:`torch.dtype` \u003Cspan class=\"hljs-keyword\">as\u003C/span> this tensor.\n    device (:\u003Cspan class=\"hljs-keyword\">class\u003C/span>:`torch.device`, optional): the desired device of returned tensor.\n        Default: \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-literal\">None\u003C/span>, same :\u003Cspan class=\"hljs-keyword\">class\u003C/span>:`torch.device` \u003Cspan class=\"hljs-keyword\">as\u003C/span> this tensor.\n    requires_grad (\u003Cspan class=\"hljs-built_in\">bool\u003C/span>, optional): If autograd should record operations on the\n        returned tensor. Default: ``\u003Cspan class=\"hljs-literal\">False\u003C/span>``.\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>8. Returns Section (if needed)\u003C/h3>\n\u003Cp>Document the return value:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">Returns:\n    Tensor: Sampled tensor of same shape \u003Cspan class=\"hljs-keyword\">as\u003C/span> `logits` \u003Cspan class=\"hljs-keyword\">from\u003C/span> the Gumbel-Softmax distribution.\n        If ``hard=\u003Cspan class=\"hljs-literal\">True\u003C/span>``, the returned samples will be one-hot, otherwise they will\n        be probability distributions that \u003Cspan class=\"hljs-built_in\">sum\u003C/span> to \u003Cspan class=\"hljs-number\">1\u003C/span> across `dim`.\u003C/code>\u003C/pre>\u003C/div>\u003Cp>Or simply include it in the function signature line if obvious from context.\u003C/p>\n\u003Ch3>9. Examples Section\u003C/h3>\n\u003Cp>Always include examples when possible:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">Examples::\n\n    &gt;&gt;&gt; inputs = torch.randn(\u003Cspan class=\"hljs-number\">33\u003C/span>, \u003Cspan class=\"hljs-number\">16\u003C/span>, \u003Cspan class=\"hljs-number\">30\u003C/span>)\n    &gt;&gt;&gt; filters = torch.randn(\u003Cspan class=\"hljs-number\">20\u003C/span>, \u003Cspan class=\"hljs-number\">16\u003C/span>, \u003Cspan class=\"hljs-number\">5\u003C/span>)\n    &gt;&gt;&gt; F.conv1d(inputs, filters)\n\n    &gt;&gt;&gt; \u003Cspan class=\"hljs-comment\"># With square kernels and equal stride\u003C/span>\n    &gt;&gt;&gt; filters = torch.randn(\u003Cspan class=\"hljs-number\">8\u003C/span>, \u003Cspan class=\"hljs-number\">4\u003C/span>, \u003Cspan class=\"hljs-number\">3\u003C/span>, \u003Cspan class=\"hljs-number\">3\u003C/span>)\n    &gt;&gt;&gt; inputs = torch.randn(\u003Cspan class=\"hljs-number\">1\u003C/span>, \u003Cspan class=\"hljs-number\">4\u003C/span>, \u003Cspan class=\"hljs-number\">5\u003C/span>, \u003Cspan class=\"hljs-number\">5\u003C/span>)\n    &gt;&gt;&gt; F.conv2d(inputs, filters, padding=\u003Cspan class=\"hljs-number\">1\u003C/span>)\u003C/code>\u003C/pre>\u003C/div>\u003Cp>\u003Cstrong>Formatting rules:\u003C/strong>\u003C/p>\n\u003Cul>\n\u003Cli>Use \u003Ccode>Examples::\u003C/code> with double colon\u003C/li>\n\u003Cli>Use \u003Ccode>&gt;&gt;&gt;\u003C/code> prompt for Python code\u003C/li>\n\u003Cli>Include comments with \u003Ccode>#\u003C/code> when helpful\u003C/li>\n\u003Cli>Show actual output when it helps understanding (indent without \u003Ccode>&gt;&gt;&gt;\u003C/code>)\u003C/li>\n\u003C/ul>\n\u003Ch3>10. External References\u003C/h3>\n\u003Cp>Link to papers or external documentation:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">.. _Link Name:\n    https://arxiv.org/\u003Cspan class=\"hljs-built_in\">abs\u003C/span>/\u003Cspan class=\"hljs-number\">1611.00712\u003C/span>\u003C/code>\u003C/pre>\u003C/div>\u003Cp>Reference them in text: \u003Ccode>See `Link Name`_\u003C/code>\u003C/p>\n\u003Ch2>Method Types\u003C/h2>\n\u003Ch3>Native Python Functions\u003C/h3>\n\u003Cp>For regular Python functions, use a standard docstring:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">relu\u003C/span>(\u003Cspan class=\"hljs-params\">\u003Cspan class=\"hljs-built_in\">input\u003C/span>: Tensor, inplace: \u003Cspan class=\"hljs-built_in\">bool\u003C/span> = \u003Cspan class=\"hljs-literal\">False\u003C/span>\u003C/span>) -&gt; Tensor:\n    \u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;relu(input, inplace=False) -&gt; Tensor\n\n    Applies the rectified linear unit function element-wise. See\n    :class:`~torch.nn.ReLU` for more details.\n    &quot;&quot;&quot;\u003C/span>\n    \u003Cspan class=\"hljs-comment\"># implementation\u003C/span>\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>C-Bound Functions (using add_docstr)\u003C/h3>\n\u003Cp>For C-bound functions, use \u003Ccode>_add_docstr\u003C/code>:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">conv1d = _add_docstr(\n    torch.conv1d,\n    \u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;\nconv1d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -&gt; Tensor\n\nApplies a 1D convolution over an input signal composed of several input\nplanes.\n\nSee :class:`~torch.nn.Conv1d` for details and output shape.\n\nArgs:\n    input: input tensor of shape :math:`(\\text{minibatch} , \\text{in\\_channels} , iW)`\n    weight: filters of shape :math:`(\\text{out\\_channels} , kW)`\n    ...\n&quot;&quot;&quot;\u003C/span>,\n)\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>In-Place Variants\u003C/h3>\n\u003Cp>For in-place operations (ending with \u003Ccode>_\u003C/code>), reference the original:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">add_docstr_all(\n    \u003Cspan class=\"hljs-string\">&quot;abs_&quot;\u003C/span>,\n    \u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;\nabs_() -&gt; Tensor\n\nIn-place version of :meth:`~Tensor.abs`\n&quot;&quot;&quot;\u003C/span>,\n)\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>Alias Functions\u003C/h3>\n\u003Cp>For aliases, simply reference the original:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">add_docstr_all(\n    \u003Cspan class=\"hljs-string\">&quot;absolute&quot;\u003C/span>,\n    \u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;\nabsolute() -&gt; Tensor\n\nAlias for :func:`abs`\n&quot;&quot;&quot;\u003C/span>,\n)\u003C/code>\u003C/pre>\u003C/div>\u003Ch2>Common Patterns\u003C/h2>\n\u003Ch3>Shape Documentation\u003C/h3>\n\u003Cp>Use LaTeX math notation for tensor shapes:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">:math:`(\\text{minibatch} , \\text{\u003Cspan class=\"hljs-keyword\">in\u003C/span>\\_channels} , iH , iW)`\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>Reusable Argument Definitions\u003C/h3>\n\u003Cp>For commonly used arguments, define them once and reuse:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">common_args = parse_kwargs(\n    \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;\n    dtype (:class:`torch.dtype`, optional): the desired type of returned tensor.\n        Default: if None, same as this tensor.\n&quot;&quot;&quot;\u003C/span>\n)\n\n\u003Cspan class=\"hljs-comment\"># Then use with .format():\u003C/span>\n\u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;\n...\n\nKeyword args:\n    {dtype}\n    {device}\n&quot;&quot;&quot;\u003C/span>.\u003Cspan class=\"hljs-built_in\">format\u003C/span>(**common_args)\u003C/code>\u003C/pre>\u003C/div>\u003Ch3>Template Insertion\u003C/h3>\n\u003Cp>Insert reproducibility notes or other common text:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;\n{tf32_note}\n\n{cudnn_reproducibility_note}\n&quot;&quot;&quot;\u003C/span>.\u003Cspan class=\"hljs-built_in\">format\u003C/span>(**reproducibility_notes, **tf32_notes)\u003C/code>\u003C/pre>\u003C/div>\u003Ch2>Complete Example\u003C/h2>\n\u003Cp>Here&#39;s a complete example showing all elements:\u003C/p>\n\u003Cdiv class=\"md-code-block\">\u003Cdiv class=\"md-code-lang\">python\u003C/div>\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">gumbel_softmax\u003C/span>(\u003Cspan class=\"hljs-params\">\n    logits: Tensor,\n    tau: \u003Cspan class=\"hljs-built_in\">float\u003C/span> = \u003Cspan class=\"hljs-number\">1\u003C/span>,\n    hard: \u003Cspan class=\"hljs-built_in\">bool\u003C/span> = \u003Cspan class=\"hljs-literal\">False\u003C/span>,\n    eps: \u003Cspan class=\"hljs-built_in\">float\u003C/span> = \u003Cspan class=\"hljs-number\">1e-10\u003C/span>,\n    dim: \u003Cspan class=\"hljs-built_in\">int\u003C/span> = -\u003Cspan class=\"hljs-number\">1\u003C/span>,\n\u003C/span>) -&gt; Tensor:\n    \u003Cspan class=\"hljs-string\">r&quot;&quot;&quot;\n    Sample from the Gumbel-Softmax distribution and optionally discretize.\n\n    Args:\n        logits (Tensor): `[..., num_features]` unnormalized log probabilities\n        tau (float): non-negative scalar temperature\n        hard (bool): if ``True``, the returned samples will be discretized as one-hot vectors,\n              but will be differentiated as if it is the soft sample in autograd. Default: ``False``\n        dim (int): A dimension along which softmax will be computed. Default: -1\n\n    Returns:\n        Tensor: Sampled tensor of same shape as `logits` from the Gumbel-Softmax distribution.\n            If ``hard=True``, the returned samples will be one-hot, otherwise they will\n            be probability distributions that sum to 1 across `dim`.\n\n    .. note::\n        This function is here for legacy reasons, may be removed from nn.Functional in the future.\n\n    Examples::\n        &gt;&gt;&gt; logits = torch.randn(20, 32)\n        &gt;&gt;&gt; # Sample soft categorical using reparametrization trick:\n        &gt;&gt;&gt; F.gumbel_softmax(logits, tau=1, hard=False)\n        &gt;&gt;&gt; # Sample hard categorical using &quot;Straight-through&quot; trick:\n        &gt;&gt;&gt; F.gumbel_softmax(logits, tau=1, hard=True)\n\n    .. _Link 1:\n        https://arxiv.org/abs/1611.00712\n    &quot;&quot;&quot;\u003C/span>\n    \u003Cspan class=\"hljs-comment\"># implementation\u003C/span>\u003C/code>\u003C/pre>\u003C/div>\u003Ch2>Quick Checklist\u003C/h2>\n\u003Cp>When writing a PyTorch docstring, ensure:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Use raw string (\u003Ccode>r&quot;&quot;&quot;\u003C/code>)\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Include function signature on first line\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Provide brief description\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Document all parameters in Args section with types\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Include default values for optional parameters\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Use Sphinx cross-references (\u003Ccode>:func:\u003C/code>, \u003Ccode>:class:\u003C/code>, \u003Ccode>:meth:\u003C/code>)\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Add mathematical formulas if applicable\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Include at least one example in Examples section\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Add warnings/notes for important caveats\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Link to related module class with \u003Ccode>:class:\u003C/code>\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Use proper math notation for tensor shapes\u003C/li>\n\u003Cli>\u003Cinput disabled=\"\" type=\"checkbox\"> Follow consistent formatting and indentation\u003C/li>\n\u003C/ul>\n\u003Ch2>Common Sphinx Roles Reference\u003C/h2>\n\u003Cul>\n\u003Cli>\u003Ccode>:class:\\\u003C/code>~torch.nn.Module`` - Class reference\u003C/li>\n\u003Cli>\u003Ccode>:func:\\\u003C/code>torch.function`` - Function reference\u003C/li>\n\u003Cli>\u003Ccode>:meth:\\\u003C/code>~Tensor.method`` - Method reference\u003C/li>\n\u003Cli>\u003Ccode>:attr:\\\u003C/code>attribute`` - Attribute reference\u003C/li>\n\u003Cli>\u003Ccode>:math:\\\u003C/code>equation`` - Inline math\u003C/li>\n\u003Cli>\u003Ccode>:ref:\\\u003C/code>label`` - Internal reference\u003C/li>\n\u003Cli>\u003Ccode>``code``\u003C/code> - Inline code (use double backticks)\u003C/li>\n\u003C/ul>\n\u003Ch2>Additional Notes\u003C/h2>\n\u003Cul>\n\u003Cli>\u003Cstrong>Indentation\u003C/strong>: Use 4 spaces for code, 2 spaces for continuation of parameter descriptions\u003C/li>\n\u003Cli>\u003Cstrong>Line length\u003C/strong>: Try to keep lines under 100 characters when possible\u003C/li>\n\u003Cli>\u003Cstrong>Periods\u003C/strong>: End sentences with periods, but not the signature line\u003C/li>\n\u003Cli>\u003Cstrong>Backticks\u003C/strong>: Use double backticks for code: \u003Ccode>``True`` ``None`` ``False``\u003C/code>\u003C/li>\n\u003Cli>\u003Cstrong>Types\u003C/strong>: Common types are \u003Ccode>Tensor\u003C/code>, \u003Ccode>int\u003C/code>, \u003Ccode>float\u003C/code>, \u003Ccode>bool\u003C/code>, \u003Ccode>str\u003C/code>, \u003Ccode>tuple\u003C/code>, \u003Ccode>list\u003C/code>, etc.\u003C/li>\n\u003C/ul>\n"]