class_docstr: This ``Estimator`` can be used to easily train and evaluate any GluonTS
  model on any dataset (own or built-in) in AWS Sagemaker using the provided
  Docker container. It also allows for the execution of custom scripts on AWS
  Sagemaker. Training is started by calling :meth:`GluonTSFramework.train` on
  this Estimator. After training is complete, calling
  :meth:`~sagemaker.amazon.estimator.Framework.deploy` creates a hosted
  SageMaker endpoint and returns an :class:`GluonTSPredictor` instance that
  can be used to perform inference against the hosted model. Alternatively,
  one can call the :meth:`GluonTSFramework.run` method to run a custom script
  defined by the "entry_point" argument of the :meth:`GluonTSFramework.run`
  method. Technical documentation on preparing GluonTSFramework scripts for
  SageMaker training and using the GluonTsFramework Estimator is available on
  the project home-page: https://github.com/awslabs/gluonts. See
  how_to_notebooks for examples of how to use this SDK.
  
  Parameters
  ----------
  sagemaker_session:
      Session object which manages interactions with Amazon SageMaker APIs
      and any other AWS services needed.
  role:
      An AWS IAM role (either name or full ARN). The Amazon SageMaker
      training jobs and APIs that create Amazon SageMaker endpoints use this
      role to access training data and model artifacts. After the endpoint is
      created, the inference code might use the IAM role, if it needs to
      access an AWS resource.
  image_uri:
      The estimator will use this image for training and hosting. It must be
      an ECR url. If you use an image with MXNET with GPU support, you will
      have to use a GPU instance.
      Example::
  
          '123.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0'
  
  base_job_name:
      Prefix for training job name when the :meth:`GluonTSFramework.train` or
      :meth:`GluonTSFramework.run` method is called.
  instance_type:
      Type of EC2 instance to use for training.
      Example::
  
          'ml.c5.xlarge' # CPU,
          'ml.p2.xlarge' # GPU
  
  instance_count:
      Currently not more than one supported.
      Otherwise the number of Amazon EC2 instances to use for training.
  dependencies:
      A list of paths to files or directories (absolute or relative) with any
      additional libraries that will be exported to the container. The
      library folders will be copied to SageMaker in the same folder where
      the "train.py" is copied. Include a path to a "requirements.txt" to
      install further dependencies at runtime. The provided dependencies take
      precedence over the pre-installed ones. If 'git_config' is provided,
      'dependencies' should be a list of relative locations to directories
      with any additional libraries needed in the Git repo.
      Example::
  
          GluonTSFramework(
              entry_point='train.py',
              dependencies=['my/libs/common', 'requirements.txt']
          )
  
      results in the following inside the container::
  
          opt/ml/code
               ├---> train.py
               ├---> common
               └---> requirements.txt
  
      To use a custom GluonTS version just import your custom GluonTS version
      and then call::
  
           GluonTSFramework(
              entry_point='train.py',
              dependencies=[gluonts.__path__[0]]
          )
  
      This may brake the :meth:`GluonTSFramework.train` method though. If not
      specified, them dependencies from the Estimator will be used.
  output_path:
      S3 location for saving the transform result. If not specified, results
      are stored to a default bucket.
  code_location:
      The S3 prefix URI where custom code will be uploaded. The code file
      uploaded in S3 is 'code_location/source/sourcedir.tar.gz'. If not
      specified, the default code location is s3://default_bucket/job-name/.
      And code file uploaded to S3 is
      s3://default_bucket/job-name/source/sourcedir.tar.gz
  framework_version:
      GluonTS version. If not specified, this will default to 0.4.1.
      Currently has no effect.
  hyperparameters:
      # TODO add support for HPO
      Not the Estimator hyperparameters, those are provided through the
      Estimator in the :meth:`GluonTSFramework.train` method. If you use the
      :meth:`GluonTSFramework.run` method its up to you what you do with this
      parameter and you could use it to define the hyperparameters of your
      models. There is no support for Hyper Parameter Optimization (HPO) so
      far. In general hyperparameters will be used for training. They 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.
  entry_point:
      Should not be overwritten if you intend to use the
      :meth:`GluonTSFramework.train` method, and only be specified through
      the :meth:`GluonTSFramework.run` method.
  **kwargs:
      Additional kwargs passed to the :class:`~sagemaker.estimator.Framework`
      constructor.
docstr: Create a ``GluonTSModel`` object that can be deployed to an
  ``Endpoint``.
  
  Parameters
  ----------
  model_server_workers:
      The number of worker processes used by the inference server. If
      None, server will use one worker per vCPU.
  role:
      An AWS IAM role (either name or full ARN). The Amazon SageMaker
      training jobs and APIs that create Amazon SageMaker endpoints use
      this role to access training data and model artifacts. After the
      endpoint is created, the inference code might use the IAM role, if
      it needs to access an AWS resource. If not specified, the role from
      the Estimator will be used.
  vpc_config_override:
      Optional override for VpcConfig set on the model. Default: use
      subnets and security groups from this Estimator.
      * 'Subnets' (list[str]): List of subnet ids.
      * 'SecurityGroupIds' (list[str]): List of security group ids.
  entry_point:
      Should not be overwritten if you intend to use the
      :meth:`GluonTSFramework.train` method, and only be specified
      through the :meth:`GluonTSFramework.run` method.
  source_dir:
      If you set this, your training script will have to be located
      within the specified source_dir and you will have to set
      entry_point to the relative path within your source_dir.
  
      Path (absolute, relative, or an S3 URI) to a directory with all
      training source code including dependencies. Structure within this
      directory is preserved when training on Amazon SageMaker. If
      'git_config' is provided, 'source_dir' should be a relative
      location to a directory in the Git repo. For example with the
      following GitHub repo directory structure::
  
          |---> README.md
          └---> src
            |---> train.py
            └---> test.py
  
      and you need 'train.py' as entry point and 'test.py' as training
      source code as well, you must set entry_point='train.py',
      source_dir='src'. If not specified, the model source directory from
      training is used.
  dependencies:
      A list of paths to files or directories (absolute or relative) with
      any additional libraries that will be exported to the container.
      The library folders will be copied to SageMaker in the same folder
      where the "train.py" is copied. Include a path to a
      "requirements.txt" to install further dependencies at runtime. The
      provided dependencies take precedence over the pre-installed ones.
      If 'git_config' is provided, 'dependencies' should be a list of
      relative locations to directories with any additional libraries
      needed in the Git repo.
      Example::
  
          GluonTSFramework(
              entry_point='train.py',
              dependencies=['my/libs/common', 'requirements.txt']
          )
  
      results in the following inside the container::
  
          opt/ml/code
              ├---> train.py
              ├---> common
              └---> requirements.txt
  
      To use a custom GluonTS version just import your custom GluonTS
      version and then call::
  
           GluonTSFramework(
              entry_point='train.py',
              dependencies=[gluonts.__path__[0]]
          )
  
      This may brake the :meth:`GluonTSFramework.train` method though.
      If not specified, them dependencies from the Estimator will be
      used.
  image_uri:
      The estimator will use this image for training and hosting. It must
      be an ECR url. If you use an image with MXNET with GPU support, you
      will have to use a GPU instance.
      Example::
  
           '123.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0'
           'custom-image:latest'
  
      If not specified, them image from the Estimator will be used.
  **kwargs:
      Additional kwargs passed to the GluonTSModel constructor.
  
  Returns
  -------
      gluonts.sagemaker.GluonTSModel
          A ``GluonTSModel`` object.
          See :func:`~gluonts.sagemaker.GluonTSModel` for full details.
docstr_tok: ["Create","a","``","GluonTSModel","``","object","that","can","be","deployed","to","an","``","Endpoint","``",".","Parameters","--","--","--","--","--","model_server_workers",":","The","number","of","worker","processes","used","by","the","inference","server",".","If","None",",","server","will","use","one","worker","per","vCPU",".","role",":","An","AWS","IAM","role","(","either","name","or","full","ARN",")",".","The","Amazon","SageMaker","training","jobs","and","APIs","that","create","Amazon","SageMaker","endpoints","use","this","role","to","access","training","data","and","model","artifacts",".","After","the","endpoint","is","created",",","the","inference","code","might","use","the","IAM","role",",","if","it","needs","to","access","an","AWS","resource",".","If","not","specified",",","the","role","from","the","Estimator","will","be","used",".","vpc_config_override",":","Optional","override","for","VpcConfig","set","on","the","model",".","Default",":","use","subnets","and","security","groups","from","this","Estimator",".","*","'Subnets","'","(","list","[","str","]",")",":","List","of","subnet","ids",".","*","'SecurityGroupIds","'","(","list","[","str","]",")",":","List","of","security","group","ids",".","entry_point",":","Should","not","be","overwritten","if","you","intend","to","use","the",":","meth",":","`","GluonTSFramework.train","`","method",",","and","only","be","specified","through","the",":","meth",":","`","GluonTSFramework.run","`","method",".","source_dir",":","If","you","set","this",",","your","training","script","will","have","to","be","located","within","the","specified","source_dir","and","you","will","have","to","set","entry_point","to","the","relative","path","within","your","source_dir",".","Path","(","absolute",",","relative",",","or","an","S3","URI",")","to","a","directory","with","all","training","source","code","including","dependencies",".","Structure","within","this","directory","is","preserved","when","training","on","Amazon","SageMaker",".","If","'git_config","'","is","provided",",","'source_dir","'","should","be","a","relative","location","to","a","directory","in","the","Git","repo",".","For","example","with","the","following","GitHub","repo","directory","structure",":",":","|","--","-",">","README.md","\u2514","--","-",">","src","|","--","-",">","train.py","\u2514","--","-",">","test.py","and","you","need","'train.py","'","as","entry","point","and","'test.py","'","as","training","source","code","as","well",",","you","must","set","entry_point='train.py","'",",","source_dir='src","'",".","If","not","specified",",","the","model","source","directory","from","training","is","used",".","dependencies",":","A","list","of","paths","to","files","or","directories","(","absolute","or","relative",")","with","any","additional","libraries","that","will","be","exported","to","the","container",".","The","library","folders","will","be","copied","to","SageMaker","in","the","same","folder","where","the","``","train.py","''","is","copied",".","Include","a","path","to","a","``","requirements.txt","''","to","install","further","dependencies","at","runtime",".","The","provided","dependencies","take","precedence","over","the","pre-installed","ones",".","If","'git_config","'","is","provided",",","'dependencies","'","should","be","a","list","of","relative","locations","to","directories","with","any","additional","libraries","needed","in","the","Git","repo",".","Example",":",":","GluonTSFramework","(","entry_point='train.py","'",",","dependencies=","[","'my\/libs\/common","'",",","'requirements.txt","'","]",")","results","in","the","following","inside","the","container",":",":","opt\/ml\/code","\u251c","--","-",">","train.py","\u251c","--","-",">","common","\u2514","--","-",">","requirements.txt","To","use","a","custom","GluonTS","version","just","import","your","custom","GluonTS","version","and","then","call",":",":","GluonTSFramework","(","entry_point='train.py","'",",","dependencies=","[","gluonts.__path__","[","0","]","]",")","This","may","brake","the",":","meth",":","`","GluonTSFramework.train","`","method","though",".","If","not","specified",",","them","dependencies","from","the","Estimator","will","be","used",".","image_uri",":","The","estimator","will","use","this","image","for","training","and","hosting",".","It","must","be","an","ECR","url",".","If","you","use","an","image","with","MXNET","with","GPU","support",",","you","will","have","to","use","a","GPU","instance",".","Example",":",":","'123.dkr.ecr.us-west-2.amazonaws.com\/my-custom-image:1.0'","'custom-image",":","latest'","If","not","specified",",","them","image","from","the","Estimator","will","be","used",".","*","*","kwargs",":","Additional","kwargs","passed","to","the","GluonTSModel","constructor",".","Returns","--","--","--","-","gluonts.sagemaker.GluonTSModel","A","``","GluonTSModel","``","object",".","See",":","func",":","`","~gluonts.sagemaker.GluonTSModel","`","for","full","details","."]
code: def create_model(
      self,
      model_server_workers: Optional[str] = None,
      role: str = None,
      vpc_config_override: Optional[
          Dict[str, List[str]]
      ] = VPC_CONFIG_DEFAULT,
      entry_point: str = None,
      source_dir: str = None,
      dependencies: List[str] = None,
      image_uri: str = None,
      **kwargs,
  ) -> GluonTSModel:
      """
      Create a ``GluonTSModel`` object that can be deployed to an
      ``Endpoint``.
  
      Parameters
      ----------
      model_server_workers:
          The number of worker processes used by the inference server. If
          None, server will use one worker per vCPU.
      role:
          An AWS IAM role (either name or full ARN). The Amazon SageMaker
          training jobs and APIs that create Amazon SageMaker endpoints use
          this role to access training data and model artifacts. After the
          endpoint is created, the inference code might use the IAM role, if
          it needs to access an AWS resource. If not specified, the role from
          the Estimator will be used.
      vpc_config_override:
          Optional override for VpcConfig set on the model. Default: use
          subnets and security groups from this Estimator.
          * 'Subnets' (list[str]): List of subnet ids.
          * 'SecurityGroupIds' (list[str]): List of security group ids.
      entry_point:
          Should not be overwritten if you intend to use the
          :meth:`GluonTSFramework.train` method, and only be specified
          through the :meth:`GluonTSFramework.run` method.
      source_dir:
          If you set this, your training script will have to be located
          within the specified source_dir and you will have to set
          entry_point to the relative path within your source_dir.
  
          Path (absolute, relative, or an S3 URI) to a directory with all
          training source code including dependencies. Structure within this
          directory is preserved when training on Amazon SageMaker. If
          'git_config' is provided, 'source_dir' should be a relative
          location to a directory in the Git repo. For example with the
          following GitHub repo directory structure::
  
              |---> README.md
              └---> src
                |---> train.py
                └---> test.py
  
          and you need 'train.py' as entry point and 'test.py' as training
          source code as well, you must set entry_point='train.py',
          source_dir='src'. If not specified, the model source directory from
          training is used.
      dependencies:
          A list of paths to files or directories (absolute or relative) with
          any additional libraries that will be exported to the container.
          The library folders will be copied to SageMaker in the same folder
          where the "train.py" is copied. Include a path to a
          "requirements.txt" to install further dependencies at runtime. The
          provided dependencies take precedence over the pre-installed ones.
          If 'git_config' is provided, 'dependencies' should be a list of
          relative locations to directories with any additional libraries
          needed in the Git repo.
          Example::
  
              GluonTSFramework(
                  entry_point='train.py',
                  dependencies=['my/libs/common', 'requirements.txt']
              )
  
          results in the following inside the container::
  
              opt/ml/code
                  ├---> train.py
                  ├---> common
                  └---> requirements.txt
  
          To use a custom GluonTS version just import your custom GluonTS
          version and then call::
  
               GluonTSFramework(
                  entry_point='train.py',
                  dependencies=[gluonts.__path__[0]]
              )
  
          This may brake the :meth:`GluonTSFramework.train` method though.
          If not specified, them dependencies from the Estimator will be
          used.
      image_uri:
          The estimator will use this image for training and hosting. It must
          be an ECR url. If you use an image with MXNET with GPU support, you
          will have to use a GPU instance.
          Example::
  
               '123.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0'
               'custom-image:latest'
  
          If not specified, them image from the Estimator will be used.
      **kwargs:
          Additional kwargs passed to the GluonTSModel constructor.
  
      Returns
      -------
          gluonts.sagemaker.GluonTSModel
              A ``GluonTSModel`` object.
              See :func:`~gluonts.sagemaker.GluonTSModel` for full details.
      """
  
      return GluonTSModel(
          self.model_data,
          role or self.role,
          entry_point or self.entry_point,
          source_dir=(source_dir or self._model_source_dir()),
          enable_cloudwatch_metrics=self.enable_cloudwatch_metrics,
          name=self._current_job_name,
          container_log_level=self.container_log_level,
          code_location=self.code_location,
          framework_version=self.framework_version,
          image_uri=(image_uri or self.image_uri),
          model_server_workers=model_server_workers,
          sagemaker_session=self.sagemaker_session,
          vpc_config=self.get_vpc_config(vpc_config_override),
          dependencies=(dependencies or self.dependencies),
      )
  
imports: import json
  import logging
  import tarfile
  from functools import partial
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Dict, List, NamedTuple, Optional, Tuple, Union
  import pandas
  import s3fs
  import sagemaker
  from sagemaker.estimator import Framework
  from sagemaker.s3 import parse_s3_url
  from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
  from gluonts.core import serde
  from gluonts.dataset.repository import datasets
  from gluonts.model.estimator import Estimator
  from gluonts.model.predictor import Predictor
  from gluonts.util import safe_extractall
  from .defaults import ENTRY_POINTS_FOLDER, FRAMEWORK_NAME, GLUONTS_VERSION, LATEST_GLUONTS_VERSION, LOWEST_SCRIPT_MODE_VERSION, MONITORED_METRICS, NUM_SAMPLES, PYTHON_VERSION, QUANTILES, TRAIN_SCRIPT
  from .model import GluonTSModel
  from .utils import make_job_name, make_metrics
label_desc: Use image node_id 2 for calling the GluonTSFramework obj's underlying member method code with example usage: obj.create_model(model_server_workers, role, vpc_config_override, entry_point, source_dir, dependencies, image_uri) and returns: GluonTSModel