<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Pedro Caldeira</title>
    <description>The latest articles on Forem by Pedro Caldeira (@pdrocaldeira).</description>
    <link>https://forem.com/pdrocaldeira</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F381131%2Febc06e12-ef9d-42f8-baa7-31726cf287f3.png</url>
      <title>Forem: Pedro Caldeira</title>
      <link>https://forem.com/pdrocaldeira</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pdrocaldeira"/>
    <language>en</language>
    <item>
      <title>Exploring Python Environments with PyEnv</title>
      <dc:creator>Pedro Caldeira</dc:creator>
      <pubDate>Mon, 11 Dec 2023 01:14:35 +0000</pubDate>
      <link>https://forem.com/pdrocaldeira/exploring-python-environments-with-pyenv-3o91</link>
      <guid>https://forem.com/pdrocaldeira/exploring-python-environments-with-pyenv-3o91</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Python developers often encounter scenarios where they must manage multiple Python versions and virtual environments. This is where &lt;code&gt;pyenv&lt;/code&gt; comes to the rescue. &lt;code&gt;pyenv&lt;/code&gt; is a simple yet powerful tool that allows you to easily install, manage, and switch between different Python versions on your system.&lt;/p&gt;

&lt;p&gt;In this blog post, we'll explore the fundamental operations of &lt;code&gt;pyenv&lt;/code&gt;, including installation, creating and managing environments, and utilizing the virtualenv plugin for more advanced use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing &lt;code&gt;pyenv&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Before diving into &lt;code&gt;pyenv&lt;/code&gt;, let's install it on your machine. The process is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://pyenv.run | bash

&lt;span class="c"&gt;# Add the following to your shell profile (.bashrc, .zshrc, etc.)&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; pyenv 1&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;pyenv init &lt;span class="nt"&gt;--path&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;pyenv virtualenv-init -&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Listing Available Python Versions
&lt;/h3&gt;

&lt;p&gt;To see which Python versions are available for installation, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Installing a Python Version
&lt;/h3&gt;

&lt;p&gt;Install a specific Python version with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv &lt;span class="nb"&gt;install &lt;/span&gt;3.8.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting the Global Python Version
&lt;/h3&gt;

&lt;p&gt;Set a global Python version for your system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv global 3.8.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating a Virtual Environment
&lt;/h3&gt;

&lt;p&gt;Create a virtual environment for your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv virtualenv 3.8.12 myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Activating and Deactivating Environments
&lt;/h3&gt;

&lt;p&gt;Activate an environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv activate myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deactivate the current environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv deactivate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Usage with the Virtualenv Plugin
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;pyenv&lt;/code&gt; can be extended with plugins. One such helpful plugin is &lt;code&gt;pyenv-virtualenv&lt;/code&gt;. Install it via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/pyenv/pyenv-virtualenv.git &lt;span class="si"&gt;$(&lt;/span&gt;pyenv root&lt;span class="si"&gt;)&lt;/span&gt;/plugins/pyenv-virtualenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating Virtual Environments with the Plugin
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv virtualenv 3.8.12 myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Activating and Deactivating Environments with the Plugin
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv activate myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv deactivate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Listing Virtual Environments
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv virtualenvs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Understanding &lt;code&gt;pyenv local&lt;/code&gt;, &lt;code&gt;pyenv global&lt;/code&gt;, and &lt;code&gt;pyenv shell&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;When working with &lt;code&gt;pyenv&lt;/code&gt;, you have three main commands for managing Python versions on different levels: &lt;code&gt;pyenv local&lt;/code&gt;, &lt;code&gt;pyenv global&lt;/code&gt;, and &lt;code&gt;pyenv shell&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;pyenv local&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;pyenv local&lt;/code&gt; command allows you to set a local Python version for a specific project or directory. This is particularly useful when different projects require different Python versions. When you run &lt;code&gt;pyenv local&lt;/code&gt;, a file named &lt;code&gt;.python-version&lt;/code&gt; is created inside the project directory, specifying the desired Python version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;your_project_directory
pyenv &lt;span class="nb"&gt;local &lt;/span&gt;3.8.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a &lt;code&gt;.python-version&lt;/code&gt; file in your project directory containing the version information.&lt;/p&gt;

&lt;p&gt;Now, whenever you navigate this project directory or its subdirectories, &lt;code&gt;pyenv&lt;/code&gt; will automatically switch to the specified Python version. This local configuration is project-specific, making it convenient to manage dependencies per-project basis.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;code&gt;pyenv global&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;On the other hand, &lt;code&gt;pyenv global&lt;/code&gt; sets the global Python version for your entire system. This default Python version will be used without a local or shell-specific configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv global 3.9.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command sets the global Python version to 3.9.5. It's handy when you want to define a default Python version for your entire development environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. &lt;code&gt;pyenv shell&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;pyenv shell&lt;/code&gt; command sets a Python version for the current shell session. Unlike &lt;code&gt;pyenv local&lt;/code&gt;, it does not create a configuration file. Instead, it affects only the current shell session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyenv shell 3.7.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command sets the Python version for the current shell session to 3.7.9. It's useful for temporary changes within a terminal window.&lt;/p&gt;

&lt;h3&gt;
  
  
  Focus on &lt;code&gt;pyenv local&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The real strength of &lt;code&gt;pyenv local&lt;/code&gt; lies in its ability to create a project-specific configuration. By generating a &lt;code&gt;.python-version&lt;/code&gt; file within your project directory, &lt;code&gt;pyenv&lt;/code&gt; ensures that the correct Python version is automatically activated every time you enter that directory.&lt;/p&gt;

&lt;p&gt;This feature is especially valuable in collaborative projects or when working on multiple projects with different Python requirements. It promotes consistency and avoids conflicts by encapsulating the Python version within the project's directory.&lt;/p&gt;

&lt;p&gt;Next time you embark on a new project, consider using &lt;code&gt;pyenv local&lt;/code&gt; to manage Python versions effortlessly on a per-project basis.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In conclusion, pyenv stands out as a straightforward and efficient tool for managing Python versions and virtual environments, providing simplicity for Python-centric projects with commands like pyenv local, pyenv global, and pyenv shell. Notably, the elegance of pyenv local lies in its ability to create project-specific configurations, facilitating seamless transitions between diverse project environments. However, as the complexities of projects grow, the environment management landscape expands to encompass broader needs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/pyenv/pyenv" rel="noopener noreferrer"&gt;https://github.com/pyenv/pyenv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pyenv/pyenv-virtualenv" rel="noopener noreferrer"&gt;https://github.com/pyenv/pyenv-virtualenv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://live.staticflickr.com/1214/4607201747_2c5fa9f78b_b.jpg" rel="noopener noreferrer"&gt;Cover image&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>tooling</category>
      <category>programming</category>
    </item>
    <item>
      <title>Transitioning from Docker to Podman: Navigating Challenges and Practical Solutions</title>
      <dc:creator>Pedro Caldeira</dc:creator>
      <pubDate>Mon, 04 Dec 2023 03:43:39 +0000</pubDate>
      <link>https://forem.com/pdrocaldeira/transitioning-from-docker-to-podman-navigating-challenges-and-practical-solutions-2l3g</link>
      <guid>https://forem.com/pdrocaldeira/transitioning-from-docker-to-podman-navigating-challenges-and-practical-solutions-2l3g</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Containers in software development encapsulate applications with dependencies, offering portability and consistency across computing environments. Docker and Podman, prominent containerization platforms, provide distinct features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker Overview
&lt;/h3&gt;

&lt;p&gt;Widely adopted, Docker simplifies application creation, deployment, and management with a client-server architecture, CLI, and graphical interface. Seamless image sharing contributes to its popularity among developers and operations teams.&lt;/p&gt;

&lt;h3&gt;
  
  
  Podman Overview
&lt;/h3&gt;

&lt;p&gt;Podman, a popular alternative tool, distinguishes itself with a daemonless architecture. Operating without a central background process, it offers a CLI similar to Docker, prioritizing security and simplicity.&lt;/p&gt;

&lt;p&gt;Both Docker and Podman adhere to OCI standards, revolutionizing software development practices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;Docker's subscription-based pricing for enterprise services contrasts with Podman's open-source model, making it cost-effective for organizations. This distinction is crucial for smaller businesses seeking functionality without hefty costs. Podman's lack of a daemon adds to its appeal, providing a simpler and potentially more resource-efficient alternative for users favoring a daemonless approach to container management.&lt;/p&gt;

&lt;h1&gt;
  
  
  Exploring Podman
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Aliasing for Seamless Transition
&lt;/h2&gt;

&lt;p&gt;My initial step involved creating an alias from "docker" to "podman" and incorporating it into my &lt;code&gt;.bashrc&lt;/code&gt;. This way, I can continue using the familiar "docker" command while the underlying implementation is Podman.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;docker&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;podman

&lt;span class="nv"&gt;$ &lt;/span&gt;docker &lt;span class="nt"&gt;--version&lt;/span&gt;
podman version 4.4.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This aliasing approach is particularly handy when dealing with legacy scripts already set up for Docker, eliminating the need for immediate replacements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Daemonless Operation
&lt;/h2&gt;

&lt;p&gt;Podman's standout feature, its daemonless architecture, may pose challenges for libraries and applications previously integrated with Docker and its daemon. In a Python script example utilizing the "docker" module, attempting to initialize it resulted in the following error:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unable to initialize Docker client. Check that the Docker daemon is running and try again. Exception received from docker.from_env() command: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To resolve this issue:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify your Podman socket:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   podman info &lt;span class="nt"&gt;--format&lt;/span&gt; &lt;span class="s1"&gt;'{{.Host.RemoteSocket.Path}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Set &lt;code&gt;DOCKER_HOST&lt;/code&gt; as your Podman socket obtained in step 1.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DOCKER_HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;unix://&amp;lt;your_podman_socket_location&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Optional: Consider adding this variable to your &lt;code&gt;.bashrc&lt;/code&gt; for convenience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Addressing Permission Denied Issues
&lt;/h2&gt;

&lt;p&gt;Podman usage may encounter various issues, including permission-denied errors. For an exhaustive list of potential problems, refer to &lt;a href="https://www.redhat.com/sysadmin/container-permission-denied-errors" rel="noopener noreferrer"&gt;this resource&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In my experience, a Docker image that functioned well with Docker faced permission-denied errors with Podman. Even running with sudo did not resolve the issue.&lt;/p&gt;

&lt;p&gt;I discovered that Podman, by default, restricts Linux capabilities in its containers, leading to permission errors. To overcome this:&lt;/p&gt;

&lt;p&gt;Add &lt;code&gt;--cap-add all&lt;/code&gt; to your script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman run &lt;span class="nt"&gt;--cap-add&lt;/span&gt; all &amp;lt;your_image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While this isn't a permanent solution, it served my one-time use case. For a more robust approach, identify the necessary capabilities and replace the "all" argument accordingly. However, this provided a quick and effective resolution for a single-use scenario.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In summary, Podman presents itself as a more resourceful option than Docker, with notable strengths in security and flexibility. However, potential challenges and disruptions in transitioning should be considered, especially for projects already established on Docker. Whether the move to Podman is worth depends on your project's specific needs and requirements. If the enhanced features and resource efficiency align with your objectives, navigating the transition complexities may prove beneficial; otherwise, sticking with Docker might be the more pragmatic choice for your current setup.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>podman</category>
      <category>devops</category>
      <category>containers</category>
    </item>
    <item>
      <title>Diving into the Deep: My Inaugural PyTorch Contribution Adventure!</title>
      <dc:creator>Pedro Caldeira</dc:creator>
      <pubDate>Fri, 24 Nov 2023 02:20:51 +0000</pubDate>
      <link>https://forem.com/pdrocaldeira/diving-into-the-deep-my-inaugural-pytorch-contribution-adventure-1ecc</link>
      <guid>https://forem.com/pdrocaldeira/diving-into-the-deep-my-inaugural-pytorch-contribution-adventure-1ecc</guid>
      <description>&lt;h1&gt;
  
  
  Context
&lt;/h1&gt;

&lt;p&gt;In my quest to showcase my coding prowess in both Python and CUDA, and to prove my adeptness at seamlessly navigating diverse codebases, I sought out an opportunity for contribution. The natural choice was PyTorch, a prominent open-source machine learning library. What better way to demonstrate my versatility than by engaging with a project at the forefront of the deep learning landscape? PyTorch presented the perfect challenge, requiring a blend of Python expertise and an understanding of CUDA for efficient GPU acceleration. By diving into this vibrant community, I aimed to contribute substantively and underscore my ability to transition seamlessly between programming languages and tackle intricate, large-scale codebases. It's a journey of skill validation and a testament to my commitment to mastering the intricacies of cutting-edge technologies. 🚀🐍🔥&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding an issue
&lt;/h1&gt;

&lt;p&gt;My initial foray into contributing to PyTorch involved the crucial step of identifying a suitable issue to tackle. Navigating through the repository, I honed in on issues tagged with "good first issue" labels, recognizing them as ideal entry points for newcomers like myself. These labels serve as beacons for code changes that are not only manageable but also self-contained, providing a perfect starting ground for someone newly acquainted with the project. In this way, I aimed to ensure that my initial contribution would be a positive and constructive addition to the PyTorch codebase. The "good first issue" label became my compass, guiding me toward an opportunity to make a meaningful impact while acclimating to the intricacies of the PyTorch ecosystem. 🌱👩‍💻🔍&lt;/p&gt;

&lt;p&gt;I chose this issue: &lt;a href="https://github.com/pytorch/pytorch/issues/113198" rel="noopener noreferrer"&gt;https://github.com/pytorch/pytorch/issues/113198&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was really easy to replicate the error, and there was already a minor discussion about the starting point and some strategies.&lt;/p&gt;

&lt;p&gt;The bug was because, for CUDA tensors, a user couldn't call a &lt;code&gt;pow&lt;/code&gt; function using Tensor and Boolean as arguments. It was generating an error message about that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;In&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;In&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;---------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="nb"&gt;RuntimeError&lt;/span&gt;                              &lt;span class="nc"&gt;Traceback &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;most&lt;/span&gt; &lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Cell&lt;/span&gt; &lt;span class="n"&gt;In&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="o"&gt;----&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;false&lt;/span&gt; &lt;span class="n"&gt;INTERNAL&lt;/span&gt; &lt;span class="n"&gt;ASSERT&lt;/span&gt; &lt;span class="n"&gt;FAILED&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/home/isuruf/git/pytorch/aten/src/ATen/native/cuda/PowKernel.cu&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;199&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;please&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;bug&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;PyTorch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;invalid&lt;/span&gt; &lt;span class="n"&gt;combination&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;Pow&lt;/span&gt; &lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;common&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;Longexp&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;integral&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The maintainer wanted just to disable this possibility because sending a boolean as an exponent is kind of strange, to say the least.&lt;/p&gt;

&lt;p&gt;However, other people with the same issues were discussing that they were expecting the same already existing behaviour considering CPU tensors. Also removing this possibility could cause some compatibility breaks.&lt;/p&gt;

&lt;p&gt;Reading through Python's official documentation, I discovered that booleans in Python are a subtype of integers, so it actually made sense that someone would try to use them as an integer exponent.&lt;/p&gt;

&lt;p&gt;The last thing to convince me that this would be a good idea was:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;So I decided to write code to support a boolean as an argument, even if the maintainer wanted the opposite. As it would be a minor change, I didn't mind writing the code to bring this discussion. Sometimes, I think it's better to start a discussion with a working code to showcase the solution and its implications. It worked out in the end! 😉 &lt;/p&gt;
&lt;h1&gt;
  
  
  Starting to work
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Compiling PyTorch
&lt;/h2&gt;

&lt;p&gt;So, kicking off any software gig involves just building the darn thing as is; no tweaks are allowed. 🏗️ Sounds easy, right? Well, hold your horses! It's like trying to tame a wild beast because software projects are this crazy maze of environments and dependencies. 🤯 Getting that baseline set without messing around is a bit like laying the groundwork for an epic adventure. You gotta grasp all the nitty-gritty stuff before diving into the cool customization part. This seemingly basic step is actually a secret weapon—it’s the key to tackling all the twists and turns in the software jungle. 🌐✨&lt;/p&gt;
&lt;h3&gt;
  
  
  Compilation instructions
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/pytorch/pytorch#from-source" rel="noopener noreferrer"&gt;https://github.com/pytorch/pytorch#from-source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I won't repeat their instructions here because that is subject to change, and then whatever I write here will become obsolete.&lt;/p&gt;

&lt;p&gt;Just remember, use &lt;code&gt;conda&lt;/code&gt; because it will definitely make your life easier.&lt;/p&gt;

&lt;p&gt;When you finally type &lt;code&gt;python setup.py develop&lt;/code&gt;, be prepared to wait for some hours if you're using your personal computer. Unless you have a really high-end machine, that is going to take a while. Cross your fingers that you have more luck than me and that everything goes great so you don't have to start all over again.&lt;/p&gt;
&lt;h3&gt;
  
  
  Problem with GCC13
&lt;/h3&gt;

&lt;p&gt;My First problem was that it wasn't working for gcc13 for some CUDA code. So, I had to install gcc12 and set CC and CXX for gcc12.&lt;/p&gt;

&lt;p&gt;I don't remember exactly what it was at the time, but here's a thread from May 2023 that it's on my web history. I wonder if my errors were the same...who knows? :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://forums.developer.nvidia.com/t/strange-errors-after-system-gcc-upgraded-to-13-1-1/252441/9" rel="noopener noreferrer"&gt;https://forums.developer.nvidia.com/t/strange-errors-after-system-gcc-upgraded-to-13-1-1/252441/9&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Anyway, that was just a matter of installing GCC12 and setting CC and CXX accordingly:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yay -S gcc-12
export CC=gcc-12
export CXX=g++-12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And then compilation went ahead.&lt;/p&gt;
&lt;h3&gt;
  
  
  Build was failing for tests
&lt;/h3&gt;

&lt;p&gt;I also had to set &lt;code&gt;BUILD_TESTS=OFF&lt;/code&gt; because tests were not compilating right. &lt;/p&gt;

&lt;p&gt;Below is the file where I found all those flags and its description. I highly recommend always looking because you can always find something useful. Sometimes, you just want to disable something so you can save some compilation time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pytorch/pytorch/blob/main/setup.py" rel="noopener noreferrer"&gt;https://github.com/pytorch/pytorch/blob/main/setup.py&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  GLIBC problem
&lt;/h3&gt;

&lt;p&gt;I was having this error: &lt;code&gt;libstdc++.so.6: version GLIBCXX_3.4.32&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then I had to update my glibc with Conda. I think this might be related to my default GCC being GCC13 within my OS.&lt;/p&gt;

&lt;p&gt;But to fix that, I did the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;conda install -c conda-forge libstdcxx-ng&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I never thought that conda would have a repository that had generic dependencies, as in packages that are not directly related to Python. That is indeed an amazing tool. And now, more than even, I understand why Python has so good package managers and environment switchers. It's because it only works if everything is meticulously tightened to the same version or everything will fall apart. &lt;/p&gt;
&lt;h3&gt;
  
  
  Smoke test
&lt;/h3&gt;

&lt;p&gt;After my first compilation success, my smoke test was just opening &lt;code&gt;python&lt;/code&gt; in the PyTorch folder and checking if &lt;code&gt;import torch&lt;/code&gt; was working. As I don't have pytorch somewhere else in my machine, if that line worked, I knew that my first step was done! 💪&lt;/p&gt;
&lt;h2&gt;
  
  
  Changing code
&lt;/h2&gt;

&lt;p&gt;Embarking on large software projects for the first time can feel like diving into a code labyrinth—daunting and disorienting. Navigating through the intricacies of an expansive codebase without a roadmap can be a real head-scratcher. Having a starting point handed to you is like finding a treasure map; it might not lead you directly to the X, but it sure beats aimlessly wandering through the code wilderness. Imagine trying to trace changes from the main function—it's like a quest with no end in sight! Getting a hint or a guide in the right direction can be a game-changer, turning what seems like an impossible task into a manageable adventure. 🗺️🕵️‍♂️&lt;/p&gt;

&lt;p&gt;So my treasure map was given by a maintainer in the issue's comment section. It was called &lt;code&gt;native_functions.yaml&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can think of this file as an API descriptor of Pytorch. All the functions that are exported for the user, on Python or C++, must be described in this YAML file.&lt;/p&gt;

&lt;p&gt;More info about its description and format: &lt;a href="https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native#readme" rel="noopener noreferrer"&gt;https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native#readme&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I was trying to fix the &lt;code&gt;pow&lt;/code&gt; function, I went into this file looking for &lt;code&gt;pow&lt;/code&gt;, and then I found this block:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;func&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pow.Tensor_Scalar(Tensor self, Scalar exponent) -&amp;gt; Tensor&lt;/span&gt;
  &lt;span class="na"&gt;device_check&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NoCheck&lt;/span&gt;   &lt;span class="c1"&gt;# TensorIterator&lt;/span&gt;
  &lt;span class="na"&gt;structured_delegate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pow.Tensor_Scalar_out&lt;/span&gt;
  &lt;span class="na"&gt;variants&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;function, method&lt;/span&gt;
  &lt;span class="na"&gt;dispatch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;SparseCPU, SparseCUDA&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pow_sparse_scalar&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;core&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;pointwise&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;A skilled software developer should embrace rather than fear the challenge of delving into unfamiliar code and definitions. It's a crucial skill to be able to decipher and understand written code, even when it's initially unfamiliar. The ability to glean insights just by glancing at the code is like having a superpower—it allows you to confidently navigate complex systems.&lt;/p&gt;

&lt;p&gt;For this particular case, you can see that it has the same arguments as my broken &lt;code&gt;pow&lt;/code&gt; function (Tensor and a Scalar) and returns a Tensor. I have no idea what &lt;code&gt;structured_delegate&lt;/code&gt; means, to be honest, I still don't 😅. But I just figured that this &lt;code&gt;pow.Tensor_Scalar_out&lt;/code&gt; could be the function that I was looking for, and I was godd*mn right&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsnruitn77gz1f6vkopv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsnruitn77gz1f6vkopv.gif" alt="Godd*amn right" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found this function implementation on &lt;code&gt;cpp/Pow.cpp&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;TORCH_IMPL_FUNC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pow_Tensor_Scalar_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Scalar&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fill_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;copy_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;pow_tensor_scalar_stub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;device_type&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After identifying an issue in the code, I needed to implement a fix. The problem was with the CUDA kernel, but upon examining the code, I noticed that for exponents 0 and 1, they didn't go into CUDA because it was trivial. For &lt;code&gt;exponent=0&lt;/code&gt;, the results were always 1, and for &lt;code&gt;exponent=1&lt;/code&gt;, it was the same value. Therefore, I decided to maintain this behavior, as there's always overhead involved in calling the kernel. As native Python treats &lt;code&gt;True&lt;/code&gt; as 1 and &lt;code&gt;False&lt;/code&gt; as 0, I modified the code to the following:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;TORCH_IMPL_FUNC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pow_Tensor_Scalar_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Scalar&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Tensor&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fill_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;copy_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;pow_tensor_scalar_stub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;device_type&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After fixing I built my code again and tested if my changes did something recreating the scenario that the ticket creator has tried. Great success, no error message anymore!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Python&lt;/span&gt; &lt;span class="mf"&gt;3.12&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;packaged&lt;/span&gt; &lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="n"&gt;Anaconda&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Inc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Oct&lt;/span&gt;  &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;help&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;copyright&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;credits&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;license&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda:0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda:0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Submitting the PR
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Preparation
&lt;/h3&gt;

&lt;p&gt;Before diving into open source contribution, it's imperative for every aspiring contributor to thoroughly read and understand the community guidelines. These guidelines serve as the holy grail, outlining standards and instructions ranging from formatting commit messages to the nuances of crafting a PR. They detail essential information, such as required tests, legal obligations, and the community's code of conduct. Ignoring these guidelines is akin to starting a journey on the wrong foot, especially in the realm of open source where community is paramount. Trust is the bedrock of open source collaboration, and maintainers, often inundated with review requests and issues, rely on contributors to adhere to established norms. Missing a crucial step could lead to your PR being overlooked indefinitely. Therefore, approaching open source with humility, attentiveness, and a commitment to following guidelines is key—read, comprehend, and don't hesitate to seek clarification if needed. Your contributions will be all the more impactful when aligned with the community's expectations. 🌐💡&lt;/p&gt;

&lt;p&gt;For Pytorch there's:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/pytorch/pytorch/wiki/The-Ultimate-Guide-to-PyTorch-Contributions" rel="noopener noreferrer"&gt;Guide for contributions (of all kinds) &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pytorch/pytorch/blob/master/CODE_OF_CONDUCT.md" rel="noopener noreferrer"&gt;Code of conduct (Pay attention to your language, i.e. remember it's the MAIN branch, and not the word) &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pytorch/pytorch/issues/85559" rel="noopener noreferrer"&gt;Contributor License Agreement - (don't sue them)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  PR experience
&lt;/h3&gt;

&lt;p&gt;After everything I just went there and created my PR from personal branch. In my humble opinion, just go there, present yourself briefly be as polite and objective as you can.&lt;/p&gt;

&lt;p&gt;Follow the standard PR message. For PyTorch you must mention your issue with &lt;code&gt;Fixes XXXX&lt;/code&gt;. Explain your code decisions, show at least that you tested something. And be open-minded and patient, a maintainer will review your code and be prepared to criticism and don't take it personally. It's possible that you think your approach is the best one and you might be right but always respect the maintainer opinion and if he asks to change something even after your argumentation, drop your PR or make the change. Maintainers have final word for a reason, they have been there for a long time and you won't imagine the different scenarios they have seem before, they probably have a reason to deny some codes and have little to zero time to explain why they will.&lt;/p&gt;

&lt;p&gt;Back to the experience I was asked to create a test for my PR. Something that I had some trouble to understand but eventually I did 😅.&lt;/p&gt;

&lt;p&gt;PyTorch has a complex test framework that is written because of many scenarios and devices that they need to test. Is related to some annotations about what devices, input, and operations that you would like to test.&lt;/p&gt;

&lt;p&gt;Explanation is within this file: &lt;a href="https://github.com/pytorch/pytorch/blob/main/torch/testing/_internal/common_device_type.py" rel="noopener noreferrer"&gt;https://github.com/pytorch/pytorch/blob/main/torch/testing/_internal/common_device_type.py&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For my case I just had to find the &lt;code&gt;pow&lt;/code&gt; test and add &lt;code&gt;True&lt;/code&gt; and &lt;code&gt;False&lt;/code&gt; as exponents on the test input and everything was done.&lt;/p&gt;

&lt;p&gt;As I created my PR there was another person that sent me an e-mail saying that he was working on the same issue asking to work together. I added him as a co-author because it was the right thing to do for his courtesy.&lt;/p&gt;

&lt;p&gt;PR approved! 🎉&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_github-liquid-tag"&gt;
  &lt;h1&gt;
    &lt;a href="https://github.com/pytorch/pytorch/pull/114133" rel="noopener noreferrer"&gt;
      &lt;img class="github-logo" alt="GitHub logo" src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg"&gt;
      &lt;span class="issue-title"&gt;
        Check for boolean values as argument on pow function. 
      &lt;/span&gt;
      &lt;span class="issue-number"&gt;#114133&lt;/span&gt;
    &lt;/a&gt;
  &lt;/h1&gt;
  &lt;div class="github-thread"&gt;
    &lt;div class="timeline-comment-header"&gt;
      &lt;a href="https://github.com/pdrocaldeira" rel="noopener noreferrer"&gt;
        &lt;img class="github-liquid-tag-img" src="https://res.cloudinary.com/practicaldev/image/fetch/s--b0a_Bzhc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://avatars.githubusercontent.com/u/3586299%3Fv%3D4" alt="pdrocaldeira avatar"&gt;
      &lt;/a&gt;
      &lt;div class="timeline-comment-header-text"&gt;
        &lt;strong&gt;
          &lt;a href="https://github.com/pdrocaldeira" rel="noopener noreferrer"&gt;pdrocaldeira&lt;/a&gt;
        &lt;/strong&gt; posted on &lt;a href="https://github.com/pytorch/pytorch/pull/114133" rel="noopener noreferrer"&gt;&lt;time&gt;Nov 20, 2023&lt;/time&gt;&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag-github-body"&gt;
      &lt;p&gt;Hello everyone! 😄
Also @lezcano , nice to meet you! :)&lt;/p&gt;
&lt;p&gt;Sorry if I miss anything, this is my first time around here. 🙃&lt;/p&gt;
&lt;p&gt;This PR basically makes the same behaviour for cuda when using &lt;code&gt;torch.pow&lt;/code&gt;. Basically Python considers True as 1 and False as 0. I just added this check into &lt;code&gt;pow&lt;/code&gt; function. From what I understood, when I do &lt;code&gt;.equal&lt;/code&gt; for &lt;code&gt;Scalar&lt;/code&gt; that is boolean, I'm sure that types match so that won't cause more trouble.&lt;/p&gt;
&lt;p&gt;I know that the issue suggest to disable this case but that could be a little more complicated, in my humble opinion. And that can create some compability problems too, I guess.&lt;/p&gt;
&lt;p&gt;My argument is that code below is correct for native language, so I guess it does makes sense sending booleans as Scalar.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ x = True
$ x + x
2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This was my first test:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Python 3.12.0 | packaged by Anaconda, Inc. | (main, Oct  2 2023, 17:29:18) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import torch
&amp;gt;&amp;gt;&amp;gt; torch.pow(torch.tensor([1, 2], device='cuda'), True)
tensor([1, 2], device='cuda:0')
&amp;gt;&amp;gt;&amp;gt; torch.pow(torch.tensor([1, 2]), True)
tensor([1, 2])
&amp;gt;&amp;gt;&amp;gt; torch.pow(torch.tensor([1, 2]), False)
tensor([1, 1])
&amp;gt;&amp;gt;&amp;gt; torch.pow(torch.tensor([1, 2], device='cuda'), False)
tensor([1, 1], device='cuda:0')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've run &lt;code&gt;test_torch.py&lt;/code&gt; and got following results, so my guess is that I didn't break anything. I was just looking for a test that uses linear regression, as suggested.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Ran 1619 tests in 52.363s

OK (skipped=111)
[TORCH_VITAL] Dataloader.enabled         True
[TORCH_VITAL] Dataloader.basic_unit_test         TEST_VALUE_STRING
[TORCH_VITAL] CUDA.used      true

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(I can paste whole log, if necessary)&lt;/p&gt;
&lt;p&gt;If this is a bad idea overall, dont worry about it. It's not a big deal, it's actually a two line change 😅  so can we talk of how do things in a different strategy.&lt;/p&gt;
&lt;p&gt;For the record I've signed the agreement already. And I didn't run linter because it's not working 😞 . Looks like PyYaml 6.0 is broken and there's a 6.0.1 fix already but I have no idea how to update that 😅&lt;/p&gt;
&lt;p&gt;Fixes #113198&lt;/p&gt;

    &lt;/div&gt;
    &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/pytorch/pytorch/pull/114133" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>python</category>
      <category>opensource</category>
      <category>career</category>
      <category>learning</category>
    </item>
    <item>
      <title>Modernizing Legacy Code with Gradle: A Seamless Integration Journey</title>
      <dc:creator>Pedro Caldeira</dc:creator>
      <pubDate>Sun, 19 Nov 2023 21:14:35 +0000</pubDate>
      <link>https://forem.com/pdrocaldeira/modernizing-legacy-code-with-gradle-a-seamless-integration-journey-27p3</link>
      <guid>https://forem.com/pdrocaldeira/modernizing-legacy-code-with-gradle-a-seamless-integration-journey-27p3</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Gradle
&lt;/h2&gt;

&lt;p&gt;Gradle, a powerful build automation tool, has become a cornerstone in modern software development. Its flexibility, scalability, and plugin-based architecture make it ideal for managing complex build processes. This blog post explores my experience integrating a more than a decade-old codebase with Gradle, highlighting the simplicity and effectiveness of the process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Navigating a Decade-Old Codebase
&lt;/h2&gt;

&lt;p&gt;The need for a robust build system becomes evident when faced with the challenge of integrating legacy code. Gradle provides a solution that streamlines the integration process, enabling developers to modernize their projects efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Managing Multiple Main Classes with Ease
&lt;/h2&gt;

&lt;p&gt;One notable feature of Gradle is its seamless handling of projects with multiple main classes. Configuring the main class to be used is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;application {
    mainClassName = 'com.example.MainClass'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simplicity ensures that the correct entry point is invoked during application execution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Effortless Dependency Management
&lt;/h2&gt;

&lt;p&gt;Gradle simplifies the addition of dependencies with a concise syntax. Declaring dependencies is as easy as specifying the group, name, and version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies {
    implementation 'group:artifact:version'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This straightforward approach enhances code maintainability and readability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enforcing Java Version Compatibility
&lt;/h2&gt;

&lt;p&gt;Ensuring compatibility with a specific Java version is a breeze in Gradle. By setting the Java version in the build script, developers can avoid compatibility issues:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuring the Runtime Environment
&lt;/h2&gt;

&lt;p&gt;Adapting the runtime environment to accommodate configuration files is effortlessly achieved with Gradle. Adjusting the working directory allows for seamless access to configuration files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;run {
    workingDir = file('config-files-directory')
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Customizing Application Execution with Args
&lt;/h2&gt;

&lt;p&gt;Gradle facilitates the customization of application execution by allowing the inclusion of custom arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;run {
    args 'arg1', 'arg2'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This flexibility empowers developers to tailor the runtime behavior according to their specific requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Integrating legacy code with Gradle proved to be a remarkably smooth journey. The streamlined syntax, extensive documentation, and vibrant community support make Gradle an invaluable tool for any developer looking to modernize and enhance their projects. I only wish I had made the switch sooner, as Gradle's user-friendly approach made every step of the process a joy.&lt;/p&gt;

</description>
      <category>java</category>
      <category>gradle</category>
      <category>automation</category>
      <category>learning</category>
    </item>
    <item>
      <title>Mastering Consistency: Leveraging Git Commit Templates for Unified Team Commit Messages</title>
      <dc:creator>Pedro Caldeira</dc:creator>
      <pubDate>Mon, 13 Nov 2023 14:55:02 +0000</pubDate>
      <link>https://forem.com/pdrocaldeira/mastering-consistency-leveraging-git-commit-templates-for-unified-team-commit-messages-5fb</link>
      <guid>https://forem.com/pdrocaldeira/mastering-consistency-leveraging-git-commit-templates-for-unified-team-commit-messages-5fb</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the realm of collaborative coding, the harmony of a team lies not only in the lines of code but in the consistency of communication. Git commit messages, often the unsung heroes of version control, play a pivotal role in understanding the evolution of a codebase. Ensuring these messages follow a unified structure can be a game-changer for teams striving for coherence and clarity. Moreover, standardized commit messages become crucial, as they might be parsed to comply with company standards, transcending mere organization to align with broader corporate requirements. This blog explores the power of Git commit templates in fostering a shared language within a team, ensuring compliance with both internal standards and the facilitation of a seamless understanding of the project's development history.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;I've encountered numerous instances where I've overlooked the prescribed company standard for commit messages. In the rush of coding and the flurry of changes, omitting something as minor as a semicolon or missing a specific format happens all too easily. It's these moments that disrupt the flow, sending me on a scavenger hunt through documents or repositories to retrieve the correct format. The process of fixing the commit message, pushing with force, and rectifying the error becomes a detour, stealing both time and focus from the actual task at hand. These interruptions, seemingly small, can snowball into significant distractions, impeding productivity and the seamless progression of work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;To overcome this hiccup I deciced to step my git skills a little bit up and decide to set my &lt;code&gt;pre-commit-msg&lt;/code&gt; with a template that will just print for me how the standard commit message should be with a brief explanation of every section.&lt;/p&gt;

&lt;p&gt;For example, I created a &lt;code&gt;.gitmessage&lt;/code&gt; within my dotfiles folder and created a link for it to be at home folder as well.&lt;/p&gt;

&lt;p&gt;Then I just ran &lt;code&gt;git config --global commit.template ~/.gitmessage&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This makes this template default for all repositories for my user. That's not a problem for me as this machine I use only to code for my employee that uses same standard between every project.&lt;/p&gt;

&lt;p&gt;It's possible to create a definition for each project but this is out of scope for this post. But I bet it's just a matter to create a local hook inside the project folder.&lt;/p&gt;

&lt;p&gt;My &lt;code&gt;.gitmessage&lt;/code&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Mandatory Format:
#GITHUBID: [TYPE] MESSAGE
#
#TYPE    : Is one of the following:
#            feat     : new feature
#            fix      : bug fix
#GITHUBID    : GITHUB issue ID.
#MESSAGE : Brief description of the change.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;Now everytime I do a &lt;code&gt;git commit&lt;/code&gt; it will write my chosen template message below where I should write my actual commit message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Mandatory Format:
#GITHUBID: [TYPE] MESSAGE
#
#TYPE    : Is one of the following:
#            feat     : new feature
#            fix      : bug fix
#GITHUBID    : GITHUB issue ID.
#MESSAGE : Brief description of the change.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Future improvements
&lt;/h2&gt;

&lt;p&gt;With this I can only have the template easily at my screen exactly when I need it so I can't forget about it. However I still need to look some info outside, for example my Github Issue ID.&lt;/p&gt;

&lt;p&gt;One idea for the future is to just have this Issue ID while I create my new branch or something like that. Then I can parse that using an local environment variable or something like that. I will probably need another hook for changing branches. &lt;/p&gt;

&lt;p&gt;I saw some solutions that creates working branch with issue ID already and then just parses it when committing. Personally I don't like this idea because I like to have my branches with actual meaningful titles so I don't have to open github to know what they were.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.conventionalcommits.org/en/v1.0.0/" rel="noopener noreferrer"&gt;https://www.conventionalcommits.org/en/v1.0.0/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks" rel="noopener noreferrer"&gt;https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/@nicklee1/prepending-your-git-commit-messages-with-user-story-ids-3bfea00eab5a" rel="noopener noreferrer"&gt;https://medium.com/@nicklee1/prepending-your-git-commit-messages-with-user-story-ids-3bfea00eab5a&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/janniks/prepare-commit-msg" rel="noopener noreferrer"&gt;https://github.com/janniks/prepare-commit-msg&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>automation</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
