Hi all. In few research papers I have found that pseudocode for an algorithm is written in PyTorch style. Is there any format for writing these PyTorch style pseudocode. If yes, kindly post the related link.
PS: It would be beneficial if you also post some more research papers with PyTorch style pseudocode.
\usepackage[ruled,vlined]{algorithm2e}
\definecolor{commentcolor}{RGB}{110,154,155} % define comment color
\newcommand{\PyComment}[1]{\ttfamily\textcolor{commentcolor}{\# #1}} % add a "#" before the input text "#1"
\newcommand{\PyCode}[1]{\ttfamily\textcolor{black}{#1}} % \ttfamily is the code font
...
\begin{algorithm}[h]
\SetAlgoLined
\PyComment{this is a comment} \\
\PyComment{this is a comment} \\
\PyComment{} \\
\PyComment{going to have indentation} \\
\PyCode{for i in range(N):} \\
\Indp % start indent
\PyComment{your comment} \\
\PyCode{your code} \PyComment{inline comment} \\
\Indm % end indent, must end with this, else all the below text will be indented
\PyComment{this is a comment} \\
\PyCode{your code}
\caption{PyTorch-style pseudocode for your-algo}
\label{algo:your-algo}
\end{algorithm}
I use the above latex code to construct a Pytorch-Style (more to a Python-Style) pseudocode algorithm table.