class_docstr: Placeholder docstring
class_docstr_tok: ["Placeholder","docstring"]
docstr: Tar the model artifact and upload to S3 bucket, then prepare for the environment variables
docstr_tok: ["Tar","the","model","artifact","and","upload","to","S3","bucket",",","then","prepare","for","the","environment","variables"]
code: def _upload_torchserve_artifacts(
      self,
      model_path: str,
      sagemaker_session: Session,
      secret_key: str,
      s3_model_data_url: str = None,
      image: str = None,
  ):
      """Tar the model artifact and upload to S3 bucket, then prepare for the environment variables"""
      if s3_model_data_url:
          bucket, key_prefix = parse_s3_url(url=s3_model_data_url)
      else:
          bucket, key_prefix = None, None
  
      code_key_prefix = fw_utils.model_code_key_prefix(
          key_prefix, None, image
      )
  
      bucket, code_key_prefix = determine_bucket_and_prefix(
          bucket=bucket,
          key_prefix=code_key_prefix,
          sagemaker_session=sagemaker_session,
      )
  
      logger.debug(
          "Uploading the model resources to bucket=%s, key_prefix=%s.",
          bucket,
          code_key_prefix,
      )
      s3_upload_path = upload(
          sagemaker_session, model_path, bucket, code_key_prefix
      )
      logger.debug("Model resources uploaded to: %s", s3_upload_path)
  
      env_vars = {
          "SAGEMAKER_SUBMIT_DIRECTORY": "/opt/ml/model/code",
          "SAGEMAKER_PROGRAM": "inference.py",
          "SAGEMAKER_REGION": sagemaker_session.boto_region_name,
          "SAGEMAKER_CONTAINER_LOG_LEVEL": "10",
          "SAGEMAKER_SERVE_SECRET_KEY": secret_key,
          "LOCAL_PYTHON": platform.python_version(),
      }
      return s3_upload_path, env_vars
  
file_path: sagemaker-python-sdk/src/sagemaker/serve/model_server/torchserve/server.py
imports: from __future__ import absolute_import
  import requests
  import logging
  import platform
  from pathlib import Path
  from sagemaker.base_predictor import PredictorBase
  from sagemaker.session import Session
  from sagemaker.serve.utils.exceptions import LocalModelInvocationException
  from sagemaker.s3_utils import determine_bucket_and_prefix, parse_s3_url
  from sagemaker import fw_utils
  from sagemaker.serve.utils.uploader import upload
  from sagemaker.local.utils import get_docker_host
label_desc: Use image node_id 1 for calling the SageMakerTorchServe obj's underlying member method code with example usage: obj._upload_torchserve_artifacts(model_path, sagemaker_session, secret_key, s3_model_data_url, image) and returns: s3_upload_path,  env_vars