code: def main():
      # the list of runtime dependencies required by this built package
      install_requires = [
          "filelock",
          "typing-extensions>=4.8.0",
          "sympy",
          "networkx",
          "jinja2",
          "fsspec",
      ]
  
      # Parse the command line and check the arguments before we proceed with
      # building deps and setup. We need to set values so `--help` works.
      dist = Distribution()
      dist.script_name = os.path.basename(sys.argv[0])
      dist.script_args = sys.argv[1:]
      try:
          dist.parse_command_line()
      except setuptools.distutils.errors.DistutilsArgError as e:
          print(e)
          sys.exit(1)
  
      mirror_files_into_torchgen()
      if RUN_BUILD_DEPS:
          build_deps()
  
      (
          extensions,
          cmdclass,
          packages,
          entry_points,
          extra_install_requires,
      ) = configure_extension_build()
  
      install_requires += extra_install_requires
  
      extras_require = {
          "optree": ["optree>=0.9.1"],
          "opt-einsum": ["opt-einsum>=3.3"],
      }
  
      # Read in README.md for our long_description
      with open(os.path.join(cwd, "README.md"), encoding="utf-8") as f:
          long_description = f.read()
  
      version_range_max = max(sys.version_info[1], 10) + 1
      torch_package_data = [
          "py.typed",
          "bin/*",
          "test/*",
          "*.pyi",
          "_C/*.pyi",
          "cuda/*.pyi",
          "fx/*.pyi",
          "optim/*.pyi",
          "autograd/*.pyi",
          "nn/*.pyi",
          "nn/modules/*.pyi",
          "nn/parallel/*.pyi",
          "utils/data/*.pyi",
          "utils/data/datapipes/*.pyi",
          "lib/*.so*",
          "lib/*.dylib*",
          "lib/*.dll",
          "lib/*.lib",
          "lib/*.pdb",
          "lib/torch_shm_manager",
          "lib/*.h",
          "include/*.h",
          "include/ATen/*.h",
          "include/ATen/cpu/*.h",
          "include/ATen/cpu/vec/vec256/*.h",
          "include/ATen/cpu/vec/vec256/vsx/*.h",
          "include/ATen/cpu/vec/vec256/zarch/*.h",
          "include/ATen/cpu/vec/vec512/*.h",
          "include/ATen/cpu/vec/*.h",
          "include/ATen/core/*.h",
          "include/ATen/cuda/*.cuh",
          "include/ATen/cuda/*.h",
          "include/ATen/cuda/detail/*.cuh",
          "include/ATen/cuda/detail/*.h",
          "include/ATen/cudnn/*.h",
          "include/ATen/functorch/*.h",
          "include/ATen/ops/*.h",
          "include/ATen/hip/*.cuh",
          "include/ATen/hip/*.h",
          "include/ATen/hip/detail/*.cuh",
          "include/ATen/hip/detail/*.h",
          "include/ATen/hip/impl/*.h",
          "include/ATen/mps/*.h",
          "include/ATen/miopen/*.h",
          "include/ATen/detail/*.h",
          "include/ATen/native/*.h",
          "include/ATen/native/cpu/*.h",
          "include/ATen/native/cuda/*.h",
          "include/ATen/native/cuda/*.cuh",
          "include/ATen/native/hip/*.h",
          "include/ATen/native/hip/*.cuh",
          "include/ATen/native/mps/*.h",
          "include/ATen/native/quantized/*.h",
          "include/ATen/native/quantized/cpu/*.h",
          "include/ATen/native/utils/*.h",
          "include/ATen/quantized/*.h",
          "include/caffe2/serialize/*.h",
          "include/c10/*.h",
          "include/c10/macros/*.h",
          "include/c10/core/*.h",
          "include/ATen/core/boxing/*.h",
          "include/ATen/core/boxing/impl/*.h",
          "include/ATen/core/dispatch/*.h",
          "include/ATen/core/op_registration/*.h",
          "include/c10/core/impl/*.h",
          "include/c10/util/*.h",
          "include/c10/cuda/*.h",
          "include/c10/cuda/impl/*.h",
          "include/c10/hip/*.h",
          "include/c10/hip/impl/*.h",
          "include/c10/xpu/*.h",
          "include/torch/*.h",
          "include/torch/csrc/*.h",
          "include/torch/csrc/api/include/torch/*.h",
          "include/torch/csrc/api/include/torch/data/*.h",
          "include/torch/csrc/api/include/torch/data/dataloader/*.h",
          "include/torch/csrc/api/include/torch/data/datasets/*.h",
          "include/torch/csrc/api/include/torch/data/detail/*.h",
          "include/torch/csrc/api/include/torch/data/samplers/*.h",
          "include/torch/csrc/api/include/torch/data/transforms/*.h",
          "include/torch/csrc/api/include/torch/detail/*.h",
          "include/torch/csrc/api/include/torch/detail/ordered_dict.h",
          "include/torch/csrc/api/include/torch/nn/*.h",
          "include/torch/csrc/api/include/torch/nn/functional/*.h",
          "include/torch/csrc/api/include/torch/nn/options/*.h",
          "include/torch/csrc/api/include/torch/nn/modules/*.h",
          "include/torch/csrc/api/include/torch/nn/modules/container/*.h",
          "include/torch/csrc/api/include/torch/nn/parallel/*.h",
          "include/torch/csrc/api/include/torch/nn/utils/*.h",
          "include/torch/csrc/api/include/torch/optim/*.h",
          "include/torch/csrc/api/include/torch/optim/schedulers/*.h",
          "include/torch/csrc/api/include/torch/serialize/*.h",
          "include/torch/csrc/autograd/*.h",
          "include/torch/csrc/autograd/functions/*.h",
          "include/torch/csrc/autograd/generated/*.h",
          "include/torch/csrc/autograd/utils/*.h",
          "include/torch/csrc/cuda/*.h",
          "include/torch/csrc/distributed/c10d/*.h",
          "include/torch/csrc/distributed/c10d/*.hpp",
          "include/torch/csrc/distributed/rpc/*.h",
          "include/torch/csrc/distributed/autograd/context/*.h",
          "include/torch/csrc/distributed/autograd/functions/*.h",
          "include/torch/csrc/distributed/autograd/rpc_messages/*.h",
          "include/torch/csrc/dynamo/*.h",
          "include/torch/csrc/inductor/*.h",
          "include/torch/csrc/inductor/aoti_runner/*.h",
          "include/torch/csrc/inductor/aoti_runtime/*.h",
          "include/torch/csrc/inductor/aoti_torch/*.h",
          "include/torch/csrc/inductor/aoti_torch/c/*.h",
          "include/torch/csrc/jit/*.h",
          "include/torch/csrc/jit/backends/*.h",
          "include/torch/csrc/jit/generated/*.h",
          "include/torch/csrc/jit/passes/*.h",
          "include/torch/csrc/jit/passes/quantization/*.h",
          "include/torch/csrc/jit/passes/utils/*.h",
          "include/torch/csrc/jit/runtime/*.h",
          "include/torch/csrc/jit/ir/*.h",
          "include/torch/csrc/jit/frontend/*.h",
          "include/torch/csrc/jit/api/*.h",
          "include/torch/csrc/jit/serialization/*.h",
          "include/torch/csrc/jit/python/*.h",
          "include/torch/csrc/jit/mobile/*.h",
          "include/torch/csrc/jit/testing/*.h",
          "include/torch/csrc/jit/tensorexpr/*.h",
          "include/torch/csrc/jit/tensorexpr/operators/*.h",
          "include/torch/csrc/jit/codegen/cuda/*.h",
          "include/torch/csrc/onnx/*.h",
          "include/torch/csrc/profiler/*.h",
          "include/torch/csrc/profiler/orchestration/*.h",
          "include/torch/csrc/profiler/stubs/*.h",
          "include/torch/csrc/profiler/unwind/*.h",
          "include/torch/csrc/utils/*.h",
          "include/torch/csrc/tensor/*.h",
          "include/torch/csrc/lazy/backend/*.h",
          "include/torch/csrc/lazy/core/*.h",
          "include/torch/csrc/lazy/core/internal_ops/*.h",
          "include/torch/csrc/lazy/core/ops/*.h",
          "include/torch/csrc/lazy/python/python_util.h",
          "include/torch/csrc/lazy/ts_backend/*.h",
          "include/pybind11/*.h",
          "include/pybind11/detail/*.h",
          "include/pybind11/eigen/*.h",
          "include/TH/*.h*",
          "include/TH/generic/*.h*",
          "include/THC/*.cuh",
          "include/THC/*.h*",
          "include/THC/generic/*.h",
          "include/THH/*.cuh",
          "include/THH/*.h*",
          "include/THH/generic/*.h",
          "include/sleef.h",
          "_inductor/codegen/*.h",
          "_inductor/codegen/aoti_runtime/*.cpp",
          "share/cmake/ATen/*.cmake",
          "share/cmake/Caffe2/*.cmake",
          "share/cmake/Caffe2/public/*.cmake",
          "share/cmake/Caffe2/Modules_CUDA_fix/*.cmake",
          "share/cmake/Caffe2/Modules_CUDA_fix/upstream/*.cmake",
          "share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/*.cmake",
          "share/cmake/Gloo/*.cmake",
          "share/cmake/Tensorpipe/*.cmake",
          "share/cmake/Torch/*.cmake",
          "utils/benchmark/utils/*.cpp",
          "utils/benchmark/utils/valgrind_wrapper/*.cpp",
          "utils/benchmark/utils/valgrind_wrapper/*.h",
          "utils/model_dump/skeleton.html",
          "utils/model_dump/code.js",
          "utils/model_dump/*.mjs",
      ]
  
      if get_cmake_cache_vars()["BUILD_CAFFE2"]:
          torch_package_data.extend(
              [
                  "include/caffe2/**/*.h",
                  "include/caffe2/utils/*.h",
                  "include/caffe2/utils/**/*.h",
              ]
          )
      if get_cmake_cache_vars()["USE_TENSORPIPE"]:
          torch_package_data.extend(
              [
                  "include/tensorpipe/*.h",
                  "include/tensorpipe/channel/*.h",
                  "include/tensorpipe/channel/basic/*.h",
                  "include/tensorpipe/channel/cma/*.h",
                  "include/tensorpipe/channel/mpt/*.h",
                  "include/tensorpipe/channel/xth/*.h",
                  "include/tensorpipe/common/*.h",
                  "include/tensorpipe/core/*.h",
                  "include/tensorpipe/transport/*.h",
                  "include/tensorpipe/transport/ibv/*.h",
                  "include/tensorpipe/transport/shm/*.h",
                  "include/tensorpipe/transport/uv/*.h",
              ]
          )
      torchgen_package_data = [
          # Recursive glob doesn't work in setup.py,
          # https://github.com/pypa/setuptools/issues/1806
          # To make this robust we should replace it with some code that
          # returns a list of everything under packaged/
          "packaged/ATen/*",
          "packaged/ATen/native/*",
          "packaged/ATen/templates/*",
          "packaged/autograd/*",
          "packaged/autograd/templates/*",
      ]
      setup(
          name=package_name,
          version=version,
          description=(
              "Tensors and Dynamic neural networks in "
              "Python with strong GPU acceleration"
          ),
          long_description=long_description,
          long_description_content_type="text/markdown",
          ext_modules=extensions,
          cmdclass=cmdclass,
          packages=packages,
          entry_points=entry_points,
          install_requires=install_requires,
          extras_require=extras_require,
          package_data={
              "torch": torch_package_data,
              "torchgen": torchgen_package_data,
              "caffe2": [
                  "python/serialized_test/data/operator_test/*.zip",
              ],
          },
          url="https://pytorch.org/",
          download_url="https://github.com/pytorch/pytorch/tags",
          author="PyTorch Team",
          author_email="packages@pytorch.org",
          python_requires=f">={python_min_version_str}",
          # PyPI package information.
          classifiers=[
              "Development Status :: 5 - Production/Stable",
              "Intended Audience :: Developers",
              "Intended Audience :: Education",
              "Intended Audience :: Science/Research",
              "License :: OSI Approved :: BSD License",
              "Topic :: Scientific/Engineering",
              "Topic :: Scientific/Engineering :: Mathematics",
              "Topic :: Scientific/Engineering :: Artificial Intelligence",
              "Topic :: Software Development",
              "Topic :: Software Development :: Libraries",
              "Topic :: Software Development :: Libraries :: Python Modules",
              "Programming Language :: C++",
              "Programming Language :: Python :: 3",
          ]
          + [
              f"Programming Language :: Python :: 3.{i}"
              for i in range(python_min_version[1], version_range_max)
          ],
          license="BSD-3",
          keywords="pytorch, machine learning",
      )
      if EMIT_BUILD_WARNING:
          print_box(build_update_message)
  
imports: import sys
  import platform
  import filecmp
  import glob
  import importlib
  import json
  import os
  import shutil
  import subprocess
  import sysconfig
  import time
  from collections import defaultdict
  import setuptools.command.build_ext
  import setuptools.command.install
  import setuptools.command.sdist
  from setuptools import Extension, find_packages, setup
  from setuptools.dist import Distribution
  from tools.build_pytorch_libs import build_caffe2
  from tools.generate_torch_version import get_torch_version
  from tools.setup_helpers.cmake import CMake
  from tools.setup_helpers.env import build_type, IS_DARWIN, IS_LINUX, IS_WINDOWS
label_desc: Use image node_id 9 for calling a global function with example usage: main() without return types