docstr: Extract the models zip; Take the serialized file and load the model
docstr_tok: ["Extract","the","models","zip",";","Take","the","serialized","file","and","load","the","model"]
code: def initialize(self, context):
      """
      Extract the models zip; Take the serialized file and load the model
      """
      properties = context.system_properties
      model_dir = properties.get("model_dir")
      gpu_id = properties.get("gpu_id")
  
      self.map_location, self.device, self.use_gpu = (
          ("cuda", torch.device("cuda:" + str(gpu_id)), True)
          if torch.cuda.is_available()
          else ("cpu", torch.device("cpu"), False)
      )
  
      # If not already extracted, Extract model source code
      if not os.path.exists(os.path.join(model_dir, "models")):
          with zipfile.ZipFile(
              os.path.join(model_dir, MODELSZIP), "r"
          ) as zip_ref:
              zip_ref.extractall(model_dir)
  
      # Load Model
      from models.DCGAN import DCGAN
  
      self.dcgan_model = DCGAN(
          useGPU=self.use_gpu, storeAVG=self.store_avg
      )
      state_dict = torch.load(
          os.path.join(model_dir, CHECKPOINT),
          map_location=self.map_location,
      )
      self.dcgan_model.load_state_dict(state_dict)
  
      self.initialized = True
  
file_path: serve/examples/dcgan_fashiongen/dcgan_fashiongen_handler.py
imports: import os
  import zipfile
  import torch
  from io import BytesIO
  from torchvision.utils import save_image
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 2 for calling the ModelHandler obj's underlying member method code with example usage: obj.initialize(context) without return types