prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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_
  
  </issue>
  <code>
  [start of docs/source/conf.py]
  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 of docs/source/conf.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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')
  
verification_info: {"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"}]}