class_docstr: A DJL SageMaker ``Model`` that can be deployed to a SageMaker ``Endpoint``.
docstr: Create a specific subclass of DJLModel for a given engine
docstr_tok: ["Create","a","specific","subclass","of","DJLModel","for","a","given","engine"]
code: def __new__(
      cls,
      model_id: str,
      *args,
      **kwargs,
  ):  # pylint: disable=W0613
      """Create a specific subclass of DJLModel for a given engine"""
      if model_id.endswith("tar.gz"):
          raise ValueError(
              "DJLModel does not support model artifacts in tar.gz format."
              "Please store the model in uncompressed format and provide the s3 uri of the "
              "containing folder"
          )
      if model_id.startswith("s3://"):
          sagemaker_session = kwargs.get("sagemaker_session")
          model_config = _get_model_config_properties_from_s3(
              model_id, sagemaker_session
          )
      else:
          hf_hub_token = kwargs.get("hf_hub_token")
          model_config = _get_model_config_properties_from_hf(
              model_id, hf_hub_token
          )
      if model_config.get("_class_name") == "StableDiffusionPipeline":
          model_type = defaults.STABLE_DIFFUSION_MODEL_TYPE
          num_heads = 0
      else:
          model_type = model_config.get("model_type")
          num_heads = model_config.get("n_head") or model_config.get(
              "num_attention_heads"
          )
      number_of_partitions = kwargs.get(
          "number_of_partitions"
      ) or kwargs.get("tensor_parallel_degree")
      cls_to_create = (
          _validate_engine_for_model_type(
              cls, model_type, number_of_partitions, num_heads
          )
          if cls is not DJLModel
          else _determine_engine_for_model(
              model_type, number_of_partitions, num_heads
          )
      )
      instance = super().__new__(cls_to_create)
      if model_type == defaults.STABLE_DIFFUSION_MODEL_TYPE:
          instance.engine = (
              DJLServingEngineEntryPointDefaults.STABLE_DIFFUSION
          )
      elif isinstance(instance, DeepSpeedModel):
          instance.engine = DJLServingEngineEntryPointDefaults.DEEPSPEED
      elif isinstance(instance, FasterTransformerModel):
          instance.engine = (
              DJLServingEngineEntryPointDefaults.FASTER_TRANSFORMER
          )
      else:
          instance.engine = (
              DJLServingEngineEntryPointDefaults.HUGGINGFACE_ACCELERATE
          )
      return instance
  
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 for calling the DJLModel obj's underlying member method code with example usage: obj.__new__(cls, model_id) and returns: instance