mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Fixes https://github.com/pytorch/tutorials/issues/3143 Pull Request resolved: https://github.com/pytorch/pytorch/pull/142018 Approved by: https://github.com/albanD
128 lines
4.9 KiB
HTML
128 lines
4.9 KiB
HTML
{% extends "!layout.html" %}
|
|
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html" />
|
|
|
|
{% block extrahead %}
|
|
{% if release == "main" %}
|
|
<!--
|
|
Search engines should not index the main version of documentation.
|
|
Stable documentation are built without release == 'main'.
|
|
-->
|
|
<meta name="robots" content="noindex">
|
|
{% endif %}
|
|
{{ super() }}
|
|
{% endblock %}
|
|
|
|
{% block menu %}
|
|
{% if release == "main" %}
|
|
<div>
|
|
<a style="color:#F05732" href="{{ theme_canonical_url }}{{ pagename }}.html">
|
|
You are viewing unstable developer preview docs.
|
|
Click here to view docs for latest stable release.
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
{{ super() }}
|
|
{% endblock %}
|
|
|
|
{% block sidebartitle %}
|
|
<div class="version">
|
|
<a href='https://pytorch.org/docs/versions.html'>{{ version }} ▼</a>
|
|
</div>
|
|
<div id="searchBox">
|
|
<div class="searchbox" id="googleSearchBox">
|
|
<script async src="https://cse.google.com/cse.js?cx=e65585f8c3ea1440e"></script>
|
|
<div class="gcse-search"></div>
|
|
</div>
|
|
<div id="sphinxSearchBox" style="display: none;">
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="{{ pathto('search') }}" method="get">
|
|
<input type="text" name="q" placeholder="Search Docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<form id="searchForm">
|
|
<label style="margin-bottom: 1rem">
|
|
<input type="radio" name="searchType" value="google" checked>
|
|
Google Search
|
|
</label>
|
|
<label style="margin-bottom: 1rem">
|
|
<input type="radio" name="searchType" value="sphinx">
|
|
Classic Search
|
|
</label>
|
|
</form>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const searchForm = document.getElementById('searchForm');
|
|
const googleSearchBox = document.getElementById('googleSearchBox');
|
|
const sphinxSearchBox = document.getElementById('sphinxSearchBox');
|
|
// Function to toggle search box visibility
|
|
function toggleSearchBox(searchType) {
|
|
googleSearchBox.style.display = searchType === 'google' ? 'block' : 'none';
|
|
sphinxSearchBox.style.display = searchType === 'sphinx' ? 'block' : 'none';
|
|
}
|
|
// Determine the default search type
|
|
let defaultSearchType;
|
|
const currentUrl = window.location.href;
|
|
if (currentUrl.startsWith('https://pytorch.org/docs/stable')) {
|
|
// For the stable documentation, default to Google
|
|
defaultSearchType = localStorage.getItem('searchType') || 'google';
|
|
} else {
|
|
// For any other version, including docs-preview, default to Sphinx
|
|
defaultSearchType = 'sphinx';
|
|
}
|
|
// Set the default search type
|
|
document.querySelector(`input[name="searchType"][value="${defaultSearchType}"]`).checked = true;
|
|
toggleSearchBox(defaultSearchType);
|
|
// Event listener for changes in search type
|
|
searchForm.addEventListener('change', function(event) {
|
|
const selectedSearchType = event.target.value;
|
|
localStorage.setItem('searchType', selectedSearchType);
|
|
toggleSearchBox(selectedSearchType);
|
|
});
|
|
// Set placeholder text for Google search box
|
|
window.onload = function() {
|
|
var placeholderText = "Search Docs";
|
|
var googleSearchboxText = document.querySelector("#gsc-i-id1");
|
|
if (googleSearchboxText) {
|
|
googleSearchboxText.placeholder = placeholderText;
|
|
googleSearchboxText.style.fontFamily = 'FreightSans';
|
|
googleSearchboxText.style.fontSize = "1.2rem";
|
|
googleSearchboxText.style.color = '#262626';
|
|
}
|
|
};
|
|
});
|
|
</script>
|
|
<!--temporarily add a link to survey -->
|
|
<div class="survey-link">
|
|
<p><i class="fas fa-poll" aria-hidden="true">  </i><a href="https://forms.gle/tdrnwJhaQ9tUePxz9">Share Your Feedback</a> about our new search</p>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{%- block content %}
|
|
{{ super() }}
|
|
<script>
|
|
|
|
var match = window.location.href.match(/\/_[a-zA-Z0-9_]*.html|_dynamo/gi);
|
|
var url = window.location.href.lastIndexOf(match[match.length-1]);
|
|
|
|
if (url)
|
|
{
|
|
var div = '<div class="admonition note"><p class="admonition-title">Note</p><p><i class="fa fa-exclamation-circle" aria-hidden="true"> </i> This page describes an internal API which is not intended to be used outside of the PyTorch codebase and can be modified or removed without notice.</p></div>'
|
|
document.getElementById("pytorch-article").insertAdjacentHTML('afterBegin', div)
|
|
}
|
|
</script>
|
|
{%- endblock %}
|
|
|
|
{% block footer %}
|
|
{{ super() }}
|
|
<script script type="text/javascript">
|
|
var collapsedSections = ['Developer Notes', 'Language Bindings', 'Libraries', 'Community'];
|
|
</script>
|
|
|
|
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&guid=ON&script=0"/>
|
|
{% endblock %}
|