class_docstr: Handle end-to-end training and deployment of custom RLEstimator code.
class_docstr_tok: ["Handle","end-to-end","training","and","deployment","of","custom","RLEstimator","code","."]
docstr: Creates an RLEstimator for managed Reinforcement Learning (RL).
  
  It will execute an RLEstimator script within a SageMaker Training Job. The managed RL
  environment is an Amazon-built Docker container that executes functions defined in the
  supplied ``entry_point`` Python script.
  
  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 based on the specified framework returns an
  :class:`~sagemaker.amazon.mxnet.model.MXNetPredictor` or
  :class:`~sagemaker.amazon.tensorflow.model.TensorFlowPredictor` instance that
  can be used to perform inference against the hosted model.
  
  Technical documentation on preparing RLEstimator scripts for
  SageMaker training and using the RLEstimator is available on the project
  homepage: 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``.
      toolkit (sagemaker.rl.RLToolkit): RL toolkit you want to use for
          executing your model training code.
      toolkit_version (str): RL toolkit version you want to be use for
          executing your model training code.
      framework (sagemaker.rl.RLFramework): Framework (MXNet or
          TensorFlow) you want to be used as a toolkit backed for
          reinforcement learning training.
      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.
      image_uri (str or PipelineVariable): An ECR url. 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. Example:
          123.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0
      metric_definitions (list[dict[str, str] or list[dict[str, PipelineVariable]]):
          A list of dictionaries that defines the metric(s) used to evaluate the
          training jobs. Each dictionary contains two keys: 'Name' for the name of the metric,
          and 'Regex' for the regular expression used to extract the
          metric from the logs. This should be defined only for jobs that
          don't use an Amazon algorithm.
      **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: ["Creates","an","RLEstimator","for","managed","Reinforcement","Learning","(","RL",")",".","It","will","execute","an","RLEstimator","script","within","a","SageMaker","Training","Job",".","The","managed","RL","environment","is","an","Amazon-built","Docker","container","that","executes","functions","defined","in","the","supplied","``","entry_point","``","Python","script",".","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","based","on","the","specified","framework","returns","an",":","class",":","`","~sagemaker.amazon.mxnet.model.MXNetPredictor","`","or",":","class",":","`","~sagemaker.amazon.tensorflow.model.TensorFlowPredictor","`","instance","that","can","be","used","to","perform","inference","against","the","hosted","model",".","Technical","documentation","on","preparing","RLEstimator","scripts","for","SageMaker","training","and","using","the","RLEstimator","is","available","on","the","project","homepage",":","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","``",".","toolkit","(","sagemaker.rl.RLToolkit",")",":","RL","toolkit","you","want","to","use","for","executing","your","model","training","code",".","toolkit_version","(","str",")",":","RL","toolkit","version","you","want","to","be","use","for","executing","your","model","training","code",".","framework","(","sagemaker.rl.RLFramework",")",":","Framework","(","MXNet","or","TensorFlow",")","you","want","to","be","used","as","a","toolkit","backed","for","reinforcement","learning","training",".","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",".","image_uri","(","str","or","PipelineVariable",")",":","An","ECR","url",".","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",".","Example",":","123.dkr.ecr.us-west-2.amazonaws.com\/my-custom-image:1.0","metric_definitions","(","list","[","dict","[","str",",","str","]","or","list","[","dict","[","str",",","PipelineVariable","]","]",")",":","A","list","of","dictionaries","that","defines","the","metric","(","s",")","used","to","evaluate","the","training","jobs",".","Each","dictionary","contains","two","keys",":","'Name","'","for","the","name","of","the","metric",",","and","'Regex","'","for","the","regular","expression","used","to","extract","the","metric","from","the","logs",".","This","should","be","defined","only","for","jobs","that","do","n't","use","an","Amazon","algorithm",".","*","*","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],
      toolkit: Optional[RLToolkit] = None,
      toolkit_version: Optional[str] = None,
      framework: Optional[Framework] = None,
      source_dir: Optional[Union[str, PipelineVariable]] = None,
      hyperparameters: Optional[
          Dict[str, Union[str, PipelineVariable]]
      ] = None,
      image_uri: Optional[Union[str, PipelineVariable]] = None,
      metric_definitions: Optional[
          List[Dict[str, Union[str, PipelineVariable]]]
      ] = None,
      **kwargs,
  ):
      """Creates an RLEstimator for managed Reinforcement Learning (RL).
  
      It will execute an RLEstimator script within a SageMaker Training Job. The managed RL
      environment is an Amazon-built Docker container that executes functions defined in the
      supplied ``entry_point`` Python script.
  
      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 based on the specified framework returns an
      :class:`~sagemaker.amazon.mxnet.model.MXNetPredictor` or
      :class:`~sagemaker.amazon.tensorflow.model.TensorFlowPredictor` instance that
      can be used to perform inference against the hosted model.
  
      Technical documentation on preparing RLEstimator scripts for
      SageMaker training and using the RLEstimator is available on the project
      homepage: 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``.
          toolkit (sagemaker.rl.RLToolkit): RL toolkit you want to use for
              executing your model training code.
          toolkit_version (str): RL toolkit version you want to be use for
              executing your model training code.
          framework (sagemaker.rl.RLFramework): Framework (MXNet or
              TensorFlow) you want to be used as a toolkit backed for
              reinforcement learning training.
          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.
          image_uri (str or PipelineVariable): An ECR url. 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. Example:
              123.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0
          metric_definitions (list[dict[str, str] or list[dict[str, PipelineVariable]]):
              A list of dictionaries that defines the metric(s) used to evaluate the
              training jobs. Each dictionary contains two keys: 'Name' for the name of the metric,
              and 'Regex' for the regular expression used to extract the
              metric from the logs. This should be defined only for jobs that
              don't use an Amazon algorithm.
          **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`.
      """
      self._validate_images_args(
          toolkit, toolkit_version, framework, image_uri
      )
  
      if not image_uri:
          self._validate_toolkit_support(
              toolkit.value, toolkit_version, framework.value
          )
          self.toolkit = toolkit.value
          self.toolkit_version = toolkit_version
          self.framework = framework.value
          self.framework_version = TOOLKIT_FRAMEWORK_VERSION_MAP[
              self.toolkit
          ][self.toolkit_version][self.framework]
  
          # set default metric_definitions based on the toolkit
          if not metric_definitions:
              metric_definitions = self.default_metric_definitions(
                  toolkit
              )
  
      super(RLEstimator, self).__init__(
          entry_point,
          source_dir,
          hyperparameters,
          image_uri=image_uri,
          metric_definitions=metric_definitions,
          **kwargs,
      )
  
imports: from __future__ import absolute_import
  import enum
  import logging
  import re
  from typing import Union, Optional, List, Dict
  from sagemaker import image_uris, fw_utils
  from sagemaker.estimator import Framework, EstimatorBase
  from sagemaker.model import FrameworkModel, SAGEMAKER_OUTPUT_LOCATION
  from sagemaker.mxnet.model import MXNetModel
  from sagemaker.tensorflow.model import TensorFlowModel
  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 RLEstimator object from inherited base classes: Framework with example: obj = RLEstimator(entry_point, toolkit, toolkit_version, framework, source_dir, hyperparameters, image_uri, metric_definitions)