class_docstr: Transformers handler class for sequence, token classification and question answering.
docstr: In this initialize function, the HF large model is loaded and
  partitioned using DeepSpeed.
  Args:
      ctx (context): It is a JSON Object containing information
      pertaining to the model artifacts parameters.
docstr_tok: ["In","this","initialize","function",",","the","HF","large","model","is","loaded","and","partitioned","using","DeepSpeed",".","Args",":","ctx","(","context",")",":","It","is","a","JSON","Object","containing","information","pertaining","to","the","model","artifacts","parameters","."]
code: def initialize(self, ctx: Context):
      """In this initialize function, the HF large model is loaded and
      partitioned using DeepSpeed.
      Args:
          ctx (context): It is a JSON Object containing information
          pertaining to the model artifacts parameters.
      """
      model_dir = ctx.system_properties.get("model_dir")
      self.max_length = int(
          ctx.model_yaml_config["handler"]["max_length"]
      )
      self.max_new_tokens = int(
          ctx.model_yaml_config["handler"]["max_new_tokens"]
      )
      model_name = ctx.model_yaml_config["handler"]["model_name"]
      model_path = f'{model_dir}/{ctx.model_yaml_config["handler"]["model_path"]}'
      seed = int(ctx.model_yaml_config["handler"]["manual_seed"])
      torch.manual_seed(seed)
  
      logger.info("Model %s loading tokenizer", ctx.model_name)
      self.model = AutoModelForCausalLM.from_pretrained(
          model_path,
          device_map="balanced",
          low_cpu_mem_usage=True,
          torch_dtype=torch.float16,
          load_in_8bit=True,
          trust_remote_code=True,
      )
      if ctx.model_yaml_config["handler"]["fast_kernels"]:
          from optimum.bettertransformer import BetterTransformer
  
          try:
              self.model = BetterTransformer.transform(self.model)
          except RuntimeError as error:
              logger.warning(
                  "HuggingFace Optimum is not supporting this model,for the list of supported models, please refer to this doc,https://huggingface.co/docs/optimum/bettertransformer/overview"
              )
      self.tokenizer = AutoTokenizer.from_pretrained(model_path)
  
      logger.info("Model %s loaded successfully", ctx.model_name)
      self.initialized = True
  
file_path: serve/examples/large_models/Huggingface_accelerate/llama2/custom_handler_code.py
imports: import logging
  from abc import ABC
  import torch
  import transformers
  from transformers import AutoModelForCausalLM, AutoTokenizer
  from ts.context import Context
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 2 for calling the LlamaHandler obj's underlying member method code with example usage: obj.initialize(ctx) without return types