class_docstr: A DJL Hugging Face SageMaker ``Model`` that can be deployed to a SageMaker ``Endpoint``.
docstr: Initialize a HuggingFaceAccelerateModel.
  
  Args:
      model_id (str): This is either the HuggingFace Hub model_id, or the Amazon S3 location
          containing the uncompressed model artifacts (i.e. not a tar.gz file).
          The model artifacts are expected to be in HuggingFace pre-trained model
          format (i.e. model should be loadable from the huggingface transformers
          from_pretrained api, and should also include tokenizer configs if applicable).
      role (str): An AWS IAM role specified with either the name or full ARN. The Amazon
          SageMaker training jobs and APIs that create Amazon SageMaker
          endpoints use this role to access model artifacts. After the endpoint is created,
          the inference code
          might use the IAM role, if it needs to access an AWS resource.
      number_of_partitions (int): The number of GPUs to partition the model across. The
          partitioning strategy is determined by the device_map setting. If device_map is
          not specified, the default HuggingFace strategy will be used.
      device_id (int): The device_id to use for instantiating the model. If provided,
          the model will only be instantiated once on the indicated device. Do not set this
          if you have also specified data_parallel_degree. Defaults to None.
      device_map (str or dict): The HuggingFace accelerate device_map to use. Defaults to
          None.
      load_in_8bit (bool): Whether to load the model in int8 precision using bits and bytes
          quantization. This is only supported for select model architectures.
          Defaults to False. If ``dtype`` is int8, then this is set to True.
      low_cpu_mem_usage (bool): Whether to limit CPU memory usage to 1x model size during
          model loading. This is an experimental feature in HuggingFace. This is useful when
          loading multiple instances of your model in parallel. Defaults to False.
      **kwargs: Keyword arguments passed to the superclasses
          :class:`~sagemaker.djl_inference.DJLModel`,
          :class:`~sagemaker.model.FrameworkModel`, and
          :class:`~sagemaker.model.Model`
  
  .. tip::
  
      You can find additional parameters for initializing this class at
      :class:`~sagemaker.djl_inference.DJLModel`,
      :class:`~sagemaker.model.FrameworkModel`, and
      :class:`~sagemaker.model.Model`.
docstr_tok: ["Initialize","a","HuggingFaceAccelerateModel",".","Args",":","model_id","(","str",")",":","This","is","either","the","HuggingFace","Hub","model_id",",","or","the","Amazon","S3","location","containing","the","uncompressed","model","artifacts","(","i.e",".","not","a","tar.gz","file",")",".","The","model","artifacts","are","expected","to","be","in","HuggingFace","pre-trained","model","format","(","i.e",".","model","should","be","loadable","from","the","huggingface","transformers","from_pretrained","api",",","and","should","also","include","tokenizer","configs","if","applicable",")",".","role","(","str",")",":","An","AWS","IAM","role","specified","with","either","the","name","or","full","ARN",".","The","Amazon","SageMaker","training","jobs","and","APIs","that","create","Amazon","SageMaker","endpoints","use","this","role","to","access","model","artifacts",".","After","the","endpoint","is","created",",","the","inference","code","might","use","the","IAM","role",",","if","it","needs","to","access","an","AWS","resource",".","number_of_partitions","(","int",")",":","The","number","of","GPUs","to","partition","the","model","across",".","The","partitioning","strategy","is","determined","by","the","device_map","setting",".","If","device_map","is","not","specified",",","the","default","HuggingFace","strategy","will","be","used",".","device_id","(","int",")",":","The","device_id","to","use","for","instantiating","the","model",".","If","provided",",","the","model","will","only","be","instantiated","once","on","the","indicated","device",".","Do","not","set","this","if","you","have","also","specified","data_parallel_degree",".","Defaults","to","None",".","device_map","(","str","or","dict",")",":","The","HuggingFace","accelerate","device_map","to","use",".","Defaults","to","None",".","load_in_8bit","(","bool",")",":","Whether","to","load","the","model","in","int8","precision","using","bits","and","bytes","quantization",".","This","is","only","supported","for","select","model","architectures",".","Defaults","to","False",".","If","``","dtype","``","is","int8",",","then","this","is","set","to","True",".","low_cpu_mem_usage","(","bool",")",":","Whether","to","limit","CPU","memory","usage","to","1x","model","size","during","model","loading",".","This","is","an","experimental","feature","in","HuggingFace",".","This","is","useful","when","loading","multiple","instances","of","your","model","in","parallel",".","Defaults","to","False",".","*","*","kwargs",":","Keyword","arguments","passed","to","the","superclasses",":","class",":","`","~sagemaker.djl_inference.DJLModel","`",",",":","class",":","`","~sagemaker.model.FrameworkModel","`",",","and",":","class",":","`","~sagemaker.model.Model","`","..","tip",":",":","You","can","find","additional","parameters","for","initializing","this","class","at",":","class",":","`","~sagemaker.djl_inference.DJLModel","`",",",":","class",":","`","~sagemaker.model.FrameworkModel","`",",","and",":","class",":","`","~sagemaker.model.Model","`","."]
code: def __init__(
      self,
      model_id: str,
      role: str,
      number_of_partitions: Optional[int] = None,
      device_id: Optional[int] = None,
      device_map: Optional[Union[str, Dict[str, str]]] = None,
      load_in_8bit: bool = False,
      low_cpu_mem_usage: bool = False,
      **kwargs,
  ):
      """Initialize a HuggingFaceAccelerateModel.
  
      Args:
          model_id (str): This is either the HuggingFace Hub model_id, or the Amazon S3 location
              containing the uncompressed model artifacts (i.e. not a tar.gz file).
              The model artifacts are expected to be in HuggingFace pre-trained model
              format (i.e. model should be loadable from the huggingface transformers
              from_pretrained api, and should also include tokenizer configs if applicable).
          role (str): An AWS IAM role specified with either the name or full ARN. The Amazon
              SageMaker training jobs and APIs that create Amazon SageMaker
              endpoints use this role to access model artifacts. After the endpoint is created,
              the inference code
              might use the IAM role, if it needs to access an AWS resource.
          number_of_partitions (int): The number of GPUs to partition the model across. The
              partitioning strategy is determined by the device_map setting. If device_map is
              not specified, the default HuggingFace strategy will be used.
          device_id (int): The device_id to use for instantiating the model. If provided,
              the model will only be instantiated once on the indicated device. Do not set this
              if you have also specified data_parallel_degree. Defaults to None.
          device_map (str or dict): The HuggingFace accelerate device_map to use. Defaults to
              None.
          load_in_8bit (bool): Whether to load the model in int8 precision using bits and bytes
              quantization. This is only supported for select model architectures.
              Defaults to False. If ``dtype`` is int8, then this is set to True.
          low_cpu_mem_usage (bool): Whether to limit CPU memory usage to 1x model size during
              model loading. This is an experimental feature in HuggingFace. This is useful when
              loading multiple instances of your model in parallel. Defaults to False.
          **kwargs: Keyword arguments passed to the superclasses
              :class:`~sagemaker.djl_inference.DJLModel`,
              :class:`~sagemaker.model.FrameworkModel`, and
              :class:`~sagemaker.model.Model`
  
      .. tip::
  
          You can find additional parameters for initializing this class at
          :class:`~sagemaker.djl_inference.DJLModel`,
          :class:`~sagemaker.model.FrameworkModel`, and
          :class:`~sagemaker.model.Model`.
      """
      if "hf_hub_token" in kwargs:
          kwargs.pop("hf_hub_token")
      super(HuggingFaceAccelerateModel, self).__init__(
          model_id,
          role,
          number_of_partitions=number_of_partitions,
          **kwargs,
      )
      self.device_id = device_id
      self.device_map = device_map
      self.load_in_8bit = load_in_8bit
      self.low_cpu_mem_usage = low_cpu_mem_usage
  
imports: from __future__ import absolute_import
  import json
  import logging
  import os.path
  import urllib.request
  from json import JSONDecodeError
  from urllib.error import HTTPError, URLError
  from enum import Enum
  from typing import Optional, Union, Dict, Any, List
  import sagemaker
  from sagemaker import s3, Predictor, image_uris, fw_utils
  from sagemaker.deserializers import JSONDeserializer, BaseDeserializer
  from sagemaker.djl_inference import defaults
  from sagemaker.model import FrameworkModel
  from sagemaker.s3_utils import s3_path_join
  from sagemaker.serializers import JSONSerializer, BaseSerializer
  from sagemaker.session import Session
  from sagemaker.utils import _tmpdir, _create_or_update_code_dir, format_tags
  from sagemaker.workflow.entities import PipelineVariable
  from sagemaker.estimator import Estimator
  from sagemaker.s3 import S3Uploader
label_desc: Use image node_id 1 to create a new HuggingFaceAccelerateModel object from inherited base classes: DJLModel with example: obj = HuggingFaceAccelerateModel(model_id, role, number_of_partitions, device_id, device_map, load_in_8bit, low_cpu_mem_usage)