class_docstr: Handle end-to-end training and deployment of custom PyTorch code.
class_docstr_tok: ["Handle","end-to-end","training","and","deployment","of","custom","PyTorch","code","."]
docstr: This ``Estimator`` executes a PyTorch script in a managed PyTorch execution environment.
  
  The managed PyTorch environment is an Amazon-built Docker container that executes functions
  defined in the supplied ``entry_point`` Python script within a SageMaker Training Job.
  
  Training is started by calling
  :meth:`~sagemaker.amazon.estimator.Framework.fit` on this Estimator.
  After training is complete, calling
  :meth:`~sagemaker.amazon.estimator.Framework.deploy` creates a hosted
  SageMaker endpoint and returns an
  :class:`~sagemaker.amazon.pytorch.model.PyTorchPredictor` instance that
  can be used to perform inference against the hosted model.
  
  Technical documentation on preparing PyTorch scripts for SageMaker
  training and using the PyTorch Estimator is available on the project
  home-page: https://github.com/aws/sagemaker-python-sdk
  
  Args:
      entry_point (str or PipelineVariable): Path (absolute or relative) to the
          Python source file which should be executed as the entry point to training.
          If ``source_dir`` is specified, then ``entry_point``
          must point to a file located at the root of ``source_dir``.
      framework_version (str): PyTorch version you want to use for
          executing your model training code. Defaults to ``None``. Required unless
          ``image_uri`` is provided. List of supported versions:
          https://github.com/aws/deep-learning-containers/blob/master/available_images.md.
      py_version (str): Python version you want to use for executing your
          model training code. One of 'py2' or 'py3'. Defaults to ``None``. Required
          unless ``image_uri`` is provided.
      source_dir (str or PipelineVariable): Path (absolute, relative or an S3 URI) to
          a directory with any other training source code dependencies aside from the entry
          point file (default: None). If ``source_dir`` is an S3 URI, it must
          point to a tar.gz file. Structure within this directory are preserved
          when training on Amazon SageMaker.
      hyperparameters (dict[str, str] or dict[str, PipelineVariable]): Hyperparameters
          that will be used for training (default: None). The hyperparameters are made
          accessible as a dict[str, str] to the training code on
          SageMaker. For convenience, this accepts other types for keys
          and values, but ``str()`` will be called to convert them before
          training.
      image_uri (str or PipelineVariable): If specified, the estimator will use this image
          for training and hosting, instead of selecting the appropriate
          SageMaker official image based on framework_version and
          py_version. It can be an ECR url or dockerhub image and tag.
          Examples:
              * ``123412341234.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0``
              * ``custom-image:latest``
  
          If ``framework_version`` or ``py_version`` are ``None``, then
          ``image_uri`` is required. If also ``None``, then a ``ValueError``
          will be raised.
      distribution (dict): A dictionary with information on how to configure and
          run distributed training
          (default: None). The following options are available.
  
          **To enable the SageMaker distributed data parallelism (SMDDP) library:**
  
              .. code:: python
  
                  { "smdistributed": { "dataparallel": { "enabled": True } } }
  
              Beside activating the SMDDP library through this parameter,
              you also need to add few lines of code in your training script
              for initializing PyTorch Distributed with the SMDDP setups.
              To learn how to configure your training job with the SMDDP library v2, see
              `Run distributed training with the SageMaker distributed data parallelism
              library
              <https://docs.aws.amazon.com/sagemaker/latest/dg/data-parallel.html>`_
              in the *Amazon SageMaker User Guide*.
  
          **To enable the SageMaker distributed model parallelism (SMP) library v2:**
  
              .. code:: python
  
                  {
                      "torch_distributed": { "enabled": True },
                      "smdistributed": {
                          "modelparallel": {
                              "enabled": True,
                              "parameters": {
                                  "tensor_parallel_degree": 8,
                                  "hybrid_shard_degree": 1,
                                  ...
                              },
                          }
                      },
                  }
  
              Beside activating the SMP library v2 through this parameter,
              you also need to add few lines of code in your training script
              for initializing PyTorch Distributed with the SMP setups.
              To learn how to configure your training job with the SMP library v2, see
              `Run distributed training with the SageMaker model parallelism library v2
              <https://docs.aws.amazon.com/sagemaker/latest/dg/model-parallel-v2.html>`_
              in the *Amazon SageMaker User Guide*.
  
              .. note::
  
                  The SageMaker distributed model parallel library v2 requires with
                  ``torch_distributed``.
  
              .. note::
  
                  The documentation for the SMP library v1.x is archived and available at
                  `Run distributed training with the SageMaker model parallelism library
                  <https://docs.aws.amazon.com/sagemaker/latest/dg/model-parallel.html>`_
                  in the *Amazon SageMaker User Guide*,
                  and the SMP v1 API reference is available in the
                  `SageMaker Python SDK v2.199.0 documentation
                  <https://sagemaker.readthedocs.io/en/v2.199.0/api/training/distributed.html#the-sagemaker-distributed-model-parallel-library>`_.
  
          **To enable PyTorch DDP:**
  
              .. code:: python
  
                  {
                      "pytorchddp": {
                          "enabled": True
                      }
                  }
  
              To learn more, see `Distributed PyTorch Training
              <https://sagemaker.readthedocs.io/en/stable/frameworks/pytorch/using_pytorch.html#distributed-pytorch-training>`_.
  
          **To enable Torch Distributed:**
  
              This is available for general distributed training on
              GPU instances from PyTorch v1.13.1 and later.
  
              .. code:: python
  
                  {
                      "torch_distributed": {
                          "enabled": True
                      }
                  }
  
              This option also supports distributed training on Trn1.
              To learn more, see `Distributed PyTorch Training on Trainium
              <https://sagemaker.readthedocs.io/en/stable/frameworks/pytorch/using_pytorch.html#distributed-pytorch-training-on-trainium>`_.
  
          **To enable MPI:**
  
              .. code:: python
  
                  {
                      "mpi": {
                          "enabled": True
                      }
                  }
  
              To learn more, see `Training with Horovod
              <https://sagemaker.readthedocs.io/en/stable/frameworks/tensorflow/using_tf.html#training-with-horovod>`_.
  
          **To enable parameter server:**
  
              .. code:: python
  
                  {
                      "parameter_server": {
                          "enabled": True
                      }
                  }
  
              To learn more, see `Training with parameter servers
              <https://sagemaker.readthedocs.io/en/stable/frameworks/tensorflow/using_tf.html#training-with-parameter-servers>`_.
  
          **To enable distributed training with SageMaker Training Compiler:**
  
              .. code:: python
  
                  {
                      "pytorchxla": {
                          "enabled": True
                      }
                  }
  
              To learn more, see `SageMaker Training Compiler
              <https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler.html>`_
              in the *Amazon SageMaker Developer Guide*.
  
              .. note::
  
                  When you use this PyTorch XLA option for distributed training strategy,
                  you must add the ``compiler_config`` parameter and activate SageMaker
                  Training Compiler.
  
          compiler_config (:class:`~sagemaker.pytorch.TrainingCompilerConfig`):
          Configures SageMaker Training Compiler to accelerate training.
  
      **kwargs: Additional kwargs passed to the :class:`~sagemaker.estimator.Framework`
          constructor.
  
  .. tip::
  
      You can find additional parameters for initializing this class at
      :class:`~sagemaker.estimator.Framework` and
      :class:`~sagemaker.estimator.EstimatorBase`.
docstr_tok: ["This","``","Estimator","``","executes","a","PyTorch","script","in","a","managed","PyTorch","execution","environment",".","The","managed","PyTorch","environment","is","an","Amazon-built","Docker","container","that","executes","functions","defined","in","the","supplied","``","entry_point","``","Python","script","within","a","SageMaker","Training","Job",".","Training","is","started","by","calling",":","meth",":","`","~sagemaker.amazon.estimator.Framework.fit","`","on","this","Estimator",".","After","training","is","complete",",","calling",":","meth",":","`","~sagemaker.amazon.estimator.Framework.deploy","`","creates","a","hosted","SageMaker","endpoint","and","returns","an",":","class",":","`","~sagemaker.amazon.pytorch.model.PyTorchPredictor","`","instance","that","can","be","used","to","perform","inference","against","the","hosted","model",".","Technical","documentation","on","preparing","PyTorch","scripts","for","SageMaker","training","and","using","the","PyTorch","Estimator","is","available","on","the","project","home-page",":","https",":","\/\/github.com\/aws\/sagemaker-python-sdk","Args",":","entry_point","(","str","or","PipelineVariable",")",":","Path","(","absolute","or","relative",")","to","the","Python","source","file","which","should","be","executed","as","the","entry","point","to","training",".","If","``","source_dir","``","is","specified",",","then","``","entry_point","``","must","point","to","a","file","located","at","the","root","of","``","source_dir","``",".","framework_version","(","str",")",":","PyTorch","version","you","want","to","use","for","executing","your","model","training","code",".","Defaults","to","``","None","``",".","Required","unless","``","image_uri","``","is","provided",".","List","of","supported","versions",":","https",":","\/\/github.com\/aws\/deep-learning-containers\/blob\/master\/available_images.md",".","py_version","(","str",")",":","Python","version","you","want","to","use","for","executing","your","model","training","code",".","One","of","'py2","'","or","'py3","'",".","Defaults","to","``","None","``",".","Required","unless","``","image_uri","``","is","provided",".","source_dir","(","str","or","PipelineVariable",")",":","Path","(","absolute",",","relative","or","an","S3","URI",")","to","a","directory","with","any","other","training","source","code","dependencies","aside","from","the","entry","point","file","(","default",":","None",")",".","If","``","source_dir","``","is","an","S3","URI",",","it","must","point","to","a","tar.gz","file",".","Structure","within","this","directory","are","preserved","when","training","on","Amazon","SageMaker",".","hyperparameters","(","dict","[","str",",","str","]","or","dict","[","str",",","PipelineVariable","]",")",":","Hyperparameters","that","will","be","used","for","training","(","default",":","None",")",".","The","hyperparameters","are","made","accessible","as","a","dict","[","str",",","str","]","to","the","training","code","on","SageMaker",".","For","convenience",",","this","accepts","other","types","for","keys","and","values",",","but","``","str","(",")","``","will","be","called","to","convert","them","before","training",".","image_uri","(","str","or","PipelineVariable",")",":","If","specified",",","the","estimator","will","use","this","image","for","training","and","hosting",",","instead","of","selecting","the","appropriate","SageMaker","official","image","based","on","framework_version","and","py_version",".","It","can","be","an","ECR","url","or","dockerhub","image","and","tag",".","Examples",":","*","``","123412341234.dkr.ecr.us-west-2.amazonaws.com\/my-custom-image:1.0","``","*","``","custom-image",":","latest","``","If","``","framework_version","``","or","``","py_version","``","are","``","None","``",",","then","``","image_uri","``","is","required",".","If","also","``","None","``",",","then","a","``","ValueError","``","will","be","raised",".","distribution","(","dict",")",":","A","dictionary","with","information","on","how","to","configure","and","run","distributed","training","(","default",":","None",")",".","The","following","options","are","available",".","*","*","To","enable","the","SageMaker","distributed","data","parallelism","(","SMDDP",")","library",":","*","*","..","code",":",":","python","{","``","smdistributed","''",":","{","``","dataparallel","''",":","{","``","enabled","''",":","True","}","}","}","Beside","activating","the","SMDDP","library","through","this","parameter",",","you","also","need","to","add","few","lines","of","code","in","your","training","script","for","initializing","PyTorch","Distributed","with","the","SMDDP","setups",".","To","learn","how","to","configure","your","training","job","with","the","SMDDP","library","v2",",","see","`","Run","distributed","training","with","the","SageMaker","distributed","data","parallelism","library","<","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/data-parallel.html",">","`","_","in","the","*","Amazon","SageMaker","User","Guide","*",".","*","*","To","enable","the","SageMaker","distributed","model","parallelism","(","SMP",")","library","v2",":","*","*","..","code",":",":","python","{","``","torch_distributed","''",":","{","``","enabled","''",":","True","}",",","``","smdistributed","''",":","{","``","modelparallel","''",":","{","``","enabled","''",":","True",",","``","parameters","''",":","{","``","tensor_parallel_degree","''",":","8",",","``","hybrid_shard_degree","''",":","1",",","...","}",",","}","}",",","}","Beside","activating","the","SMP","library","v2","through","this","parameter",",","you","also","need","to","add","few","lines","of","code","in","your","training","script","for","initializing","PyTorch","Distributed","with","the","SMP","setups",".","To","learn","how","to","configure","your","training","job","with","the","SMP","library","v2",",","see","`","Run","distributed","training","with","the","SageMaker","model","parallelism","library","v2","<","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/model-parallel-v2.html",">","`","_","in","the","*","Amazon","SageMaker","User","Guide","*",".","..","note",":",":","The","SageMaker","distributed","model","parallel","library","v2","requires","with","``","torch_distributed","``",".","..","note",":",":","The","documentation","for","the","SMP","library","v1.x","is","archived","and","available","at","`","Run","distributed","training","with","the","SageMaker","model","parallelism","library","<","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/model-parallel.html",">","`","_","in","the","*","Amazon","SageMaker","User","Guide","*",",","and","the","SMP","v1","API","reference","is","available","in","the","`","SageMaker","Python","SDK","v2.199.0","documentation","<","https",":","\/\/sagemaker.readthedocs.io\/en\/v2.199.0\/api\/training\/distributed.html","#","the-sagemaker-distributed-model-parallel-library",">","`","_",".","*","*","To","enable","PyTorch","DDP",":","*","*","..","code",":",":","python","{","``","pytorchddp","''",":","{","``","enabled","''",":","True","}","}","To","learn","more",",","see","`","Distributed","PyTorch","Training","<","https",":","\/\/sagemaker.readthedocs.io\/en\/stable\/frameworks\/pytorch\/using_pytorch.html","#","distributed-pytorch-training",">","`","_",".","*","*","To","enable","Torch","Distributed",":","*","*","This","is","available","for","general","distributed","training","on","GPU","instances","from","PyTorch","v1.13.1","and","later",".","..","code",":",":","python","{","``","torch_distributed","''",":","{","``","enabled","''",":","True","}","}","This","option","also","supports","distributed","training","on","Trn1",".","To","learn","more",",","see","`","Distributed","PyTorch","Training","on","Trainium","<","https",":","\/\/sagemaker.readthedocs.io\/en\/stable\/frameworks\/pytorch\/using_pytorch.html","#","distributed-pytorch-training-on-trainium",">","`","_",".","*","*","To","enable","MPI",":","*","*","..","code",":",":","python","{","``","mpi","''",":","{","``","enabled","''",":","True","}","}","To","learn","more",",","see","`","Training","with","Horovod","<","https",":","\/\/sagemaker.readthedocs.io\/en\/stable\/frameworks\/tensorflow\/using_tf.html","#","training-with-horovod",">","`","_",".","*","*","To","enable","parameter","server",":","*","*","..","code",":",":","python","{","``","parameter_server","''",":","{","``","enabled","''",":","True","}","}","To","learn","more",",","see","`","Training","with","parameter","servers","<","https",":","\/\/sagemaker.readthedocs.io\/en\/stable\/frameworks\/tensorflow\/using_tf.html","#","training-with-parameter-servers",">","`","_",".","*","*","To","enable","distributed","training","with","SageMaker","Training","Compiler",":","*","*","..","code",":",":","python","{","``","pytorchxla","''",":","{","``","enabled","''",":","True","}","}","To","learn","more",",","see","`","SageMaker","Training","Compiler","<","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/training-compiler.html",">","`","_","in","the","*","Amazon","SageMaker","Developer","Guide","*",".","..","note",":",":","When","you","use","this","PyTorch","XLA","option","for","distributed","training","strategy",",","you","must","add","the","``","compiler_config","``","parameter","and","activate","SageMaker","Training","Compiler",".","compiler_config","(",":","class",":","`","~sagemaker.pytorch.TrainingCompilerConfig","`",")",":","Configures","SageMaker","Training","Compiler","to","accelerate","training",".","*","*","kwargs",":","Additional","kwargs","passed","to","the",":","class",":","`","~sagemaker.estimator.Framework","`","constructor",".","..","tip",":",":","You","can","find","additional","parameters","for","initializing","this","class","at",":","class",":","`","~sagemaker.estimator.Framework","`","and",":","class",":","`","~sagemaker.estimator.EstimatorBase","`","."]
code: def __init__(
      self,
      entry_point: Union[str, PipelineVariable],
      framework_version: Optional[str] = None,
      py_version: Optional[str] = None,
      source_dir: Optional[Union[str, PipelineVariable]] = None,
      hyperparameters: Optional[
          Dict[str, Union[str, PipelineVariable]]
      ] = None,
      image_uri: Optional[Union[str, PipelineVariable]] = None,
      distribution: Optional[Dict] = None,
      compiler_config: Optional[TrainingCompilerConfig] = None,
      **kwargs,
  ):
      """This ``Estimator`` executes a PyTorch script in a managed PyTorch execution environment.
  
      The managed PyTorch environment is an Amazon-built Docker container that executes functions
      defined in the supplied ``entry_point`` Python script within a SageMaker Training Job.
  
      Training is started by calling
      :meth:`~sagemaker.amazon.estimator.Framework.fit` on this Estimator.
      After training is complete, calling
      :meth:`~sagemaker.amazon.estimator.Framework.deploy` creates a hosted
      SageMaker endpoint and returns an
      :class:`~sagemaker.amazon.pytorch.model.PyTorchPredictor` instance that
      can be used to perform inference against the hosted model.
  
      Technical documentation on preparing PyTorch scripts for SageMaker
      training and using the PyTorch Estimator is available on the project
      home-page: https://github.com/aws/sagemaker-python-sdk
  
      Args:
          entry_point (str or PipelineVariable): Path (absolute or relative) to the
              Python source file which should be executed as the entry point to training.
              If ``source_dir`` is specified, then ``entry_point``
              must point to a file located at the root of ``source_dir``.
          framework_version (str): PyTorch version you want to use for
              executing your model training code. Defaults to ``None``. Required unless
              ``image_uri`` is provided. List of supported versions:
              https://github.com/aws/deep-learning-containers/blob/master/available_images.md.
          py_version (str): Python version you want to use for executing your
              model training code. One of 'py2' or 'py3'. Defaults to ``None``. Required
              unless ``image_uri`` is provided.
          source_dir (str or PipelineVariable): Path (absolute, relative or an S3 URI) to
              a directory with any other training source code dependencies aside from the entry
              point file (default: None). If ``source_dir`` is an S3 URI, it must
              point to a tar.gz file. Structure within this directory are preserved
              when training on Amazon SageMaker.
          hyperparameters (dict[str, str] or dict[str, PipelineVariable]): Hyperparameters
              that will be used for training (default: None). The hyperparameters are made
              accessible as a dict[str, str] to the training code on
              SageMaker. For convenience, this accepts other types for keys
              and values, but ``str()`` will be called to convert them before
              training.
          image_uri (str or PipelineVariable): If specified, the estimator will use this image
              for training and hosting, instead of selecting the appropriate
              SageMaker official image based on framework_version and
              py_version. It can be an ECR url or dockerhub image and tag.
              Examples:
                  * ``123412341234.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0``
                  * ``custom-image:latest``
  
              If ``framework_version`` or ``py_version`` are ``None``, then
              ``image_uri`` is required. If also ``None``, then a ``ValueError``
              will be raised.
          distribution (dict): A dictionary with information on how to configure and
              run distributed training
              (default: None). The following options are available.
  
              **To enable the SageMaker distributed data parallelism (SMDDP) library:**
  
                  .. code:: python
  
                      { "smdistributed": { "dataparallel": { "enabled": True } } }
  
                  Beside activating the SMDDP library through this parameter,
                  you also need to add few lines of code in your training script
                  for initializing PyTorch Distributed with the SMDDP setups.
                  To learn how to configure your training job with the SMDDP library v2, see
                  `Run distributed training with the SageMaker distributed data parallelism
                  library
                  <https://docs.aws.amazon.com/sagemaker/latest/dg/data-parallel.html>`_
                  in the *Amazon SageMaker User Guide*.
  
              **To enable the SageMaker distributed model parallelism (SMP) library v2:**
  
                  .. code:: python
  
                      {
                          "torch_distributed": { "enabled": True },
                          "smdistributed": {
                              "modelparallel": {
                                  "enabled": True,
                                  "parameters": {
                                      "tensor_parallel_degree": 8,
                                      "hybrid_shard_degree": 1,
                                      ...
                                  },
                              }
                          },
                      }
  
                  Beside activating the SMP library v2 through this parameter,
                  you also need to add few lines of code in your training script
                  for initializing PyTorch Distributed with the SMP setups.
                  To learn how to configure your training job with the SMP library v2, see
                  `Run distributed training with the SageMaker model parallelism library v2
                  <https://docs.aws.amazon.com/sagemaker/latest/dg/model-parallel-v2.html>`_
                  in the *Amazon SageMaker User Guide*.
  
                  .. note::
  
                      The SageMaker distributed model parallel library v2 requires with
                      ``torch_distributed``.
  
                  .. note::
  
                      The documentation for the SMP library v1.x is archived and available at
                      `Run distributed training with the SageMaker model parallelism library
                      <https://docs.aws.amazon.com/sagemaker/latest/dg/model-parallel.html>`_
                      in the *Amazon SageMaker User Guide*,
                      and the SMP v1 API reference is available in the
                      `SageMaker Python SDK v2.199.0 documentation
                      <https://sagemaker.readthedocs.io/en/v2.199.0/api/training/distributed.html#the-sagemaker-distributed-model-parallel-library>`_.
  
              **To enable PyTorch DDP:**
  
                  .. code:: python
  
                      {
                          "pytorchddp": {
                              "enabled": True
                          }
                      }
  
                  To learn more, see `Distributed PyTorch Training
                  <https://sagemaker.readthedocs.io/en/stable/frameworks/pytorch/using_pytorch.html#distributed-pytorch-training>`_.
  
              **To enable Torch Distributed:**
  
                  This is available for general distributed training on
                  GPU instances from PyTorch v1.13.1 and later.
  
                  .. code:: python
  
                      {
                          "torch_distributed": {
                              "enabled": True
                          }
                      }
  
                  This option also supports distributed training on Trn1.
                  To learn more, see `Distributed PyTorch Training on Trainium
                  <https://sagemaker.readthedocs.io/en/stable/frameworks/pytorch/using_pytorch.html#distributed-pytorch-training-on-trainium>`_.
  
              **To enable MPI:**
  
                  .. code:: python
  
                      {
                          "mpi": {
                              "enabled": True
                          }
                      }
  
                  To learn more, see `Training with Horovod
                  <https://sagemaker.readthedocs.io/en/stable/frameworks/tensorflow/using_tf.html#training-with-horovod>`_.
  
              **To enable parameter server:**
  
                  .. code:: python
  
                      {
                          "parameter_server": {
                              "enabled": True
                          }
                      }
  
                  To learn more, see `Training with parameter servers
                  <https://sagemaker.readthedocs.io/en/stable/frameworks/tensorflow/using_tf.html#training-with-parameter-servers>`_.
  
              **To enable distributed training with SageMaker Training Compiler:**
  
                  .. code:: python
  
                      {
                          "pytorchxla": {
                              "enabled": True
                          }
                      }
  
                  To learn more, see `SageMaker Training Compiler
                  <https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler.html>`_
                  in the *Amazon SageMaker Developer Guide*.
  
                  .. note::
  
                      When you use this PyTorch XLA option for distributed training strategy,
                      you must add the ``compiler_config`` parameter and activate SageMaker
                      Training Compiler.
  
              compiler_config (:class:`~sagemaker.pytorch.TrainingCompilerConfig`):
              Configures SageMaker Training Compiler to accelerate training.
  
          **kwargs: Additional kwargs passed to the :class:`~sagemaker.estimator.Framework`
              constructor.
  
      .. tip::
  
          You can find additional parameters for initializing this class at
          :class:`~sagemaker.estimator.Framework` and
          :class:`~sagemaker.estimator.EstimatorBase`.
      """
      validate_version_or_image_args(
          framework_version, py_version, image_uri
      )
      if py_version == "py2":
          logger.warning(
              python_deprecation_warning(
                  self._framework_name, defaults.LATEST_PY2_VERSION
              )
          )
      self.framework_version = framework_version
      self.py_version = py_version
  
      if "enable_sagemaker_metrics" not in kwargs:
          # enable sagemaker metrics for PT v1.3 or greater:
          if self.framework_version and Version(
              self.framework_version
          ) >= Version("1.3"):
              kwargs["enable_sagemaker_metrics"] = True
  
      super(PyTorch, self).__init__(
          entry_point,
          source_dir,
          hyperparameters,
          image_uri=image_uri,
          **kwargs,
      )
  
      if "entry_point" not in kwargs:
          kwargs["entry_point"] = entry_point
  
      if distribution is not None:
          distribution = validate_distribution(
              distribution,
              self.instance_groups,
              self._framework_name,
              framework_version,
              py_version,
              image_uri,
              kwargs,
          )
  
      self.distribution = distribution or {}
  
      if compiler_config is not None:
          if not isinstance(compiler_config, TrainingCompilerConfig):
              error_string = (
                  f"Expected instance of type {TrainingCompilerConfig}"
                  f"for argument compiler_config. "
                  f"Instead got {type(compiler_config)}"
              )
              raise ValueError(error_string)
          if compiler_config:
              compiler_config.validate(self)
      elif distribution is not None and "pytorchxla" in distribution:
          raise ValueError(
              "Distributed training through PyTorch XLA is currently only supported "
              "when SageMaker Training Compiler is enabled. To learn more, "
              "see Enable SageMaker Training Compiler at "
              "https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler-enable.html."
          )
      self.compiler_config = compiler_config
  
      if "profiler_config" in kwargs:
          profiler_config_deprecation_warning(
              kwargs["profiler_config"],
              image_uri,
              self._framework_name,
              framework_version,
          )
  
file_path: sagemaker-python-sdk/src/sagemaker/pytorch/estimator.py
imports: from __future__ import absolute_import
  import logging
  from typing import Union, Optional, Dict
  from packaging.version import Version
  from sagemaker.estimator import Framework, EstimatorBase
  from sagemaker.fw_utils import framework_name_from_image, framework_version_from_tag, python_deprecation_warning, validate_version_or_image_args, validate_distribution, profiler_config_deprecation_warning
  from sagemaker.pytorch import defaults
  from sagemaker.pytorch.model import PyTorchModel
  from sagemaker.pytorch.training_compiler.config import TrainingCompilerConfig
  from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
  from sagemaker.workflow.entities import PipelineVariable
label_desc: Use image node_id 1 to create a new PyTorch object from inherited base classes: Framework with example: obj = PyTorch(entry_point, framework_version, py_version, source_dir, hyperparameters, image_uri, distribution, compiler_config)