docstr: First try to load torchscript else load eager mode state_dict based model
docstr_tok: ["First","try","to","load","torchscript","else","load","eager","mode","state_dict","based","model"]
code: def initialize(self, ctx):
      """First try to load torchscript else load eager mode state_dict based model"""
  
      properties = ctx.system_properties
      model_dir = properties.get("model_dir")
      if (
          not torch.cuda.is_available()
          or properties.get("gpu_id") is None
      ):
          raise RuntimeError(
              "This model is not supported on CPU machines."
          )
      self.device = torch.device(
          "cuda:" + str(properties.get("gpu_id"))
      )
  
      with zipfile.ZipFile(model_dir + "/tacotron.zip", "r") as zip_ref:
          zip_ref.extractall(model_dir)
  
      waveglow_checkpoint = torch.load(
          os.path.join(
              model_dir, "nvidia_waveglowpyt_fp32_20190427.pth"
          )
      )
      waveglow_state_dict = self._unwrap_distributed(
          waveglow_checkpoint["state_dict"]
      )
      waveglow_config = waveglow_checkpoint["config"]
      self.waveglow_model = WaveGlow(**waveglow_config)
      self.waveglow_model.load_state_dict(waveglow_state_dict)
      self.waveglow_model = self.waveglow_model.remove_weightnorm(
          self.waveglow_model
      )
      self.waveglow_model.to(self.device)
      self.waveglow_model.eval()
  
      self._load_tacotron2_model(model_dir)
  
      logger.debug("WaveGlow model file loaded successfully")
      self.initialized = True
  
file_path: serve/examples/text_to_speech_synthesizer/waveglow_handler.py
imports: import logging
  import os
  import uuid
  import zipfile
  import numpy
  import torch
  from scipy.io.wavfile import write
  from waveglow_model import WaveGlow
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 4 for calling the WaveGlowSpeechSynthesizer obj's underlying member method code with example usage: obj.initialize(ctx) without return types