code: def initialize(self, ctx):
      self.context = ctx
      properties = self.context.system_properties
      gpu_id = properties.get("gpu_id")
      if gpu_id is not None and int(gpu_id) < 0:
          raise ValueError("Invalid gpu_id")
      rank = maybe_init_dist()
  
      self.local_rank = rank if rank is not None else int(gpu_id)
  
      if torch.cuda.is_available():
          self.map_location = "cuda"
          self.device = torch.device(
              self.map_location + ":" + str(self.local_rank)
          )
  
          torch.cuda.set_device(self.local_rank)
  
      checkpoint_path = Path(
          ctx.model_yaml_config["handler"]["converted_ckpt_dir"]
      )
      assert checkpoint_path.is_file(), checkpoint_path
  
      tokenizer_path = checkpoint_path.parent / "tokenizer.model"
      assert tokenizer_path.is_file(), tokenizer_path
  
      logger.info("Loading model ...")
      t0 = time.time()
      use_tp = rank is not None
      self.model = _load_model(
          checkpoint_path, self.device, torch.bfloat16, use_tp
      )
      torch.cuda.synchronize()
      logger.info(
          f"Time to load model: {time.time() - t0:.02f} seconds"
      )
  
      draft_checkpoint_path = ctx.model_yaml_config["handler"].get(
          "draft_checkpoint_path", None
      )
      self.is_speculative = draft_checkpoint_path is not None
      if self.is_speculative:
          self.draft_model = _load_model(
              Path(draft_checkpoint_path),
              self.device,
              torch.bfloat16,
              use_tp,
          )
          self.speculate_k = ctx.model_yaml_config["handler"].get(
              "speculate_k", 8
          )
  
      self.tokenizer = SentencePieceProcessor(
          model_file=str(tokenizer_path)
      )
  
      if ctx.model_yaml_config["handler"]["compile"]:
          if self.is_speculative and use_tp:
              torch._inductor.config.triton.cudagraph_trees = (
                  False  # Bug with cudagraph trees in this case
              )
  
          if self.is_speculative:
              global model_forward
              model_forward = torch.compile(
                  model_forward, mode="reduce-overhead", fullgraph=True
              )
  
          self.decode_one_token = torch.compile(
              self.decode_one_token,
              mode="reduce-overhead",
              fullgraph=True,
          )
          self.prefill = torch.compile(
              self.prefill, fullgraph=True, dynamic=True
          )
  
      torch.manual_seed(42 * 42)
  
      self.stream = ctx.model_yaml_config["handler"].get("stream", True)
  
      self.initialized = True
  
file_path: serve/examples/large_models/gpt_fast/handler.py
imports: import json
  import logging
  import time
  from pathlib import Path
  import torch
  from generate import Transformer, _load_model, decode_one_token, encode_tokens, logits_to_probs, maybe_init_dist, model_forward, multinomial_sample_one_no_sync, prefill
  from sentencepiece import SentencePieceProcessor
  from ts.handler_utils.timer import timed
  from ts.handler_utils.utils import send_intermediate_predict_response
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 2 for calling the GptHandler obj's underlying member method code with example usage: obj.initialize(ctx) without return types