We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
LatexBuilder for docs fails
### 📚 Describe the documentation issue

The following line makes the docs building crash when using a LatexBuilder

https://github.com/pyg-team/pytorch_geometric/blob/88d7986b6d0a6de5895872270d2ff4fc95fae3b7/docs/source/conf.py#L69C1-L75C43

To reproduce build the docs with the latex builder
```bash
python -m sphinx -T -E -b latex -d _build/doctrees -D language=en . ./build
```

```bash
Extension error:
Handler <function setup.<locals>.rst_jinja_render at 0x1230b4dc0> for event 'source-read' threw an exception (exception: 'LaTeXBuilder' object has no attribute 'templates')

```

### Suggest a potential alternative/fix

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docs/source/conf.py`
Content:
```
1 import datetime
2 import os.path as osp
3 import sys
4 
5 import pyg_sphinx_theme
6 
7 import torch_geometric
8 
9 author = 'PyG Team'
10 project = 'pytorch_geometric'
11 version = torch_geometric.__version__
12 copyright = f'{datetime.datetime.now().year}, {author}'
13 
14 sys.path.append(osp.join(osp.dirname(pyg_sphinx_theme.__file__), 'extension'))
15 
16 extensions = [
17     'sphinx.ext.autodoc',
18     'sphinx.ext.autosummary',
19     'sphinx.ext.intersphinx',
20     'sphinx.ext.mathjax',
21     'sphinx.ext.napoleon',
22     'sphinx.ext.viewcode',
23     'nbsphinx',
24     'pyg',
25 ]
26 
27 html_theme = 'pyg_sphinx_theme'
28 html_logo = ('https://raw.githubusercontent.com/pyg-team/pyg_sphinx_theme/'
29              'master/pyg_sphinx_theme/static/img/pyg_logo.png')
30 html_favicon = ('https://raw.githubusercontent.com/pyg-team/pyg_sphinx_theme/'
31                 'master/pyg_sphinx_theme/static/img/favicon.png')
32 html_static_path = ['_static']
33 templates_path = ['_templates']
34 
35 add_module_names = False
36 autodoc_member_order = 'bysource'
37 
38 suppress_warnings = ['autodoc.import_object']
39 
40 intersphinx_mapping = {
41     'python': ('https://docs.python.org/', None),
42     # 'numpy': ('http://docs.scipy.org/doc/numpy', None),
43     'pandas': ('http://pandas.pydata.org/pandas-docs/dev', None),
44     'torch': ('https://pytorch.org/docs/master', None),
45 }
46 
47 nbsphinx_thumbnails = {
48     'tutorial/create_gnn':
49     '_static/thumbnails/create_gnn.png',
50     'tutorial/heterogeneous':
51     '_static/thumbnails/heterogeneous.png',
52     'tutorial/create_dataset':
53     '_static/thumbnails/create_dataset.png',
54     'tutorial/load_csv':
55     '_static/thumbnails/load_csv.png',
56     'tutorial/neighbor_loader':
57     '_static/thumbnails/neighbor_loader.png',
58     'tutorial/explain':
59     '_static/thumbnails/explain.png',
60     'tutorial/shallow_node_embeddings':
61     '_static/thumbnails/shallow_node_embeddings.png',
62     'tutorial/multi_gpu_vanilla':
63     '_static/thumbnails/multi_gpu_vanilla.png',
64     'tutorial/multi_node_multi_gpu_vanilla':
65     '_static/thumbnails/multi_gpu_vanilla.png',
66 }
67 
68 
69 def setup(app):
70     def rst_jinja_render(app, _, source):
71         rst_context = {'torch_geometric': torch_geometric}
72         source[0] = app.builder.templates.render_string(source[0], rst_context)
73 
74     app.connect('source-read', rst_jinja_render)
75     app.add_js_file('js/version_alert.js')
76
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/docs/source/conf.py b/docs/source/conf.py
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -66,10 +66,12 @@
 }
 
 
-def setup(app):
-    def rst_jinja_render(app, _, source):
+def rst_jinja_render(app, _, source):
+    if hasattr(app.builder, 'templates'):
         rst_context = {'torch_geometric': torch_geometric}
         source[0] = app.builder.templates.render_string(source[0], rst_context)
 
+
+def setup(app):
     app.connect('source-read', rst_jinja_render)
     app.add_js_file('js/version_alert.js')

{"golden_diff": "diff --git a/docs/source/conf.py b/docs/source/conf.py\n--- a/docs/source/conf.py\n+++ b/docs/source/conf.py\n@@ -66,10 +66,12 @@\n }\n \n \n-def setup(app):\n-    def rst_jinja_render(app, _, source):\n+def rst_jinja_render(app, _, source):\n+    if hasattr(app.builder, 'templates'):\n         rst_context = {'torch_geometric': torch_geometric}\n         source[0] = app.builder.templates.render_string(source[0], rst_context)\n \n+\n+def setup(app):\n     app.connect('source-read', rst_jinja_render)\n     app.add_js_file('js/version_alert.js')\n", "issue": "LatexBuilder for docs fails\n### \ud83d\udcda Describe the documentation issue\r\n\r\nThe following line makes the docs building crash when using a LatexBuilder\r\n\r\nhttps://github.com/pyg-team/pytorch_geometric/blob/88d7986b6d0a6de5895872270d2ff4fc95fae3b7/docs/source/conf.py#L69C1-L75C43\r\n\r\nTo reproduce build the docs with the latex builder\r\n```bash\r\npython -m sphinx -T -E -b latex -d _build/doctrees -D language=en . ./build\r\n```\r\n\r\n```bash\r\nExtension error:\r\nHandler <function setup.<locals>.rst_jinja_render at 0x1230b4dc0> for event 'source-read' threw an exception (exception: 'LaTeXBuilder' object has no attribute 'templates')\r\n\r\n```\r\n\r\n### Suggest a potential alternative/fix\r\n\r\n_No response_\n", "before_files": [{"content": "import datetime\nimport os.path as osp\nimport sys\n\nimport pyg_sphinx_theme\n\nimport torch_geometric\n\nauthor = 'PyG Team'\nproject = 'pytorch_geometric'\nversion = torch_geometric.__version__\ncopyright = f'{datetime.datetime.now().year}, {author}'\n\nsys.path.append(osp.join(osp.dirname(pyg_sphinx_theme.__file__), 'extension'))\n\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.autosummary',\n    'sphinx.ext.intersphinx',\n    'sphinx.ext.mathjax',\n    'sphinx.ext.napoleon',\n    'sphinx.ext.viewcode',\n    'nbsphinx',\n    'pyg',\n]\n\nhtml_theme = 'pyg_sphinx_theme'\nhtml_logo = ('https://raw.githubusercontent.com/pyg-team/pyg_sphinx_theme/'\n             'master/pyg_sphinx_theme/static/img/pyg_logo.png')\nhtml_favicon = ('https://raw.githubusercontent.com/pyg-team/pyg_sphinx_theme/'\n                'master/pyg_sphinx_theme/static/img/favicon.png')\nhtml_static_path = ['_static']\ntemplates_path = ['_templates']\n\nadd_module_names = False\nautodoc_member_order = 'bysource'\n\nsuppress_warnings = ['autodoc.import_object']\n\nintersphinx_mapping = {\n    'python': ('https://docs.python.org/', None),\n    # 'numpy': ('http://docs.scipy.org/doc/numpy', None),\n    'pandas': ('http://pandas.pydata.org/pandas-docs/dev', None),\n    'torch': ('https://pytorch.org/docs/master', None),\n}\n\nnbsphinx_thumbnails = {\n    'tutorial/create_gnn':\n    '_static/thumbnails/create_gnn.png',\n    'tutorial/heterogeneous':\n    '_static/thumbnails/heterogeneous.png',\n    'tutorial/create_dataset':\n    '_static/thumbnails/create_dataset.png',\n    'tutorial/load_csv':\n    '_static/thumbnails/load_csv.png',\n    'tutorial/neighbor_loader':\n    '_static/thumbnails/neighbor_loader.png',\n    'tutorial/explain':\n    '_static/thumbnails/explain.png',\n    'tutorial/shallow_node_embeddings':\n    '_static/thumbnails/shallow_node_embeddings.png',\n    'tutorial/multi_gpu_vanilla':\n    '_static/thumbnails/multi_gpu_vanilla.png',\n    'tutorial/multi_node_multi_gpu_vanilla':\n    '_static/thumbnails/multi_gpu_vanilla.png',\n}\n\n\ndef setup(app):\n    def rst_jinja_render(app, _, source):\n        rst_context = {'torch_geometric': torch_geometric}\n        source[0] = app.builder.templates.render_string(source[0], rst_context)\n\n    app.connect('source-read', rst_jinja_render)\n    app.add_js_file('js/version_alert.js')\n", "path": "docs/source/conf.py"}], "after_files": [{"content": "import datetime\nimport os.path as osp\nimport sys\n\nimport pyg_sphinx_theme\n\nimport torch_geometric\n\nauthor = 'PyG Team'\nproject = 'pytorch_geometric'\nversion = torch_geometric.__version__\ncopyright = f'{datetime.datetime.now().year}, {author}'\n\nsys.path.append(osp.join(osp.dirname(pyg_sphinx_theme.__file__), 'extension'))\n\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.autosummary',\n    'sphinx.ext.intersphinx',\n    'sphinx.ext.mathjax',\n    'sphinx.ext.napoleon',\n    'sphinx.ext.viewcode',\n    'nbsphinx',\n    'pyg',\n]\n\nhtml_theme = 'pyg_sphinx_theme'\nhtml_logo = ('https://raw.githubusercontent.com/pyg-team/pyg_sphinx_theme/'\n             'master/pyg_sphinx_theme/static/img/pyg_logo.png')\nhtml_favicon = ('https://raw.githubusercontent.com/pyg-team/pyg_sphinx_theme/'\n                'master/pyg_sphinx_theme/static/img/favicon.png')\nhtml_static_path = ['_static']\ntemplates_path = ['_templates']\n\nadd_module_names = False\nautodoc_member_order = 'bysource'\n\nsuppress_warnings = ['autodoc.import_object']\n\nintersphinx_mapping = {\n    'python': ('https://docs.python.org/', None),\n    # 'numpy': ('http://docs.scipy.org/doc/numpy', None),\n    'pandas': ('http://pandas.pydata.org/pandas-docs/dev', None),\n    'torch': ('https://pytorch.org/docs/master', None),\n}\n\nnbsphinx_thumbnails = {\n    'tutorial/create_gnn':\n    '_static/thumbnails/create_gnn.png',\n    'tutorial/heterogeneous':\n    '_static/thumbnails/heterogeneous.png',\n    'tutorial/create_dataset':\n    '_static/thumbnails/create_dataset.png',\n    'tutorial/load_csv':\n    '_static/thumbnails/load_csv.png',\n    'tutorial/neighbor_loader':\n    '_static/thumbnails/neighbor_loader.png',\n    'tutorial/explain':\n    '_static/thumbnails/explain.png',\n    'tutorial/shallow_node_embeddings':\n    '_static/thumbnails/shallow_node_embeddings.png',\n    'tutorial/multi_gpu_vanilla':\n    '_static/thumbnails/multi_gpu_vanilla.png',\n    'tutorial/multi_node_multi_gpu_vanilla':\n    '_static/thumbnails/multi_gpu_vanilla.png',\n}\n\n\ndef rst_jinja_render(app, _, source):\n    if hasattr(app.builder, 'templates'):\n        rst_context = {'torch_geometric': torch_geometric}\n        source[0] = app.builder.templates.render_string(source[0], rst_context)\n\n\ndef setup(app):\n    app.connect('source-read', rst_jinja_render)\n    app.add_js_file('js/version_alert.js')\n", "path": "docs/source/conf.py"}]}