class_docstr: Handler for TorchRec DLRM example
class_docstr_tok: ["Handler","for","TorchRec","DLRM","example"]
docstr: Initialize function loads the model.pt file and initialized the model object.
     This version creates and initialized the model on cpu fist and transfers to gpu in a second step to prevent GPU OOM.
  Args:
      context (context): It is a JSON Object containing information
      pertaining to the model artifacts parameters.
  Raises:
      RuntimeError: Raises the Runtime error when the model.py is missing
docstr_tok: ["Initialize","function","loads","the","model.pt","file","and","initialized","the","model","object",".","This","version","creates","and","initialized","the","model","on","cpu","fist","and","transfers","to","gpu","in","a","second","step","to","prevent","GPU","OOM",".","Args",":","context","(","context",")",":","It","is","a","JSON","Object","containing","information","pertaining","to","the","model","artifacts","parameters",".","Raises",":","RuntimeError",":","Raises","the","Runtime","error","when","the","model.py","is","missing"]
code: def initialize(self, context):
      """Initialize function loads the model.pt file and initialized the model object.
         This version creates and initialized the model on cpu fist and transfers to gpu in a second step to prevent GPU OOM.
      Args:
          context (context): It is a JSON Object containing information
          pertaining to the model artifacts parameters.
      Raises:
          RuntimeError: Raises the Runtime error when the model.py is missing
      """
      properties = context.system_properties
  
      # Set device to cpu to prevent GPU OOM errors
      self.device = "cpu"
      self.manifest = context.manifest
  
      model_dir = properties.get("model_dir")
      model_pt_path = None
      if "serializedFile" in self.manifest["model"]:
          serialized_file = self.manifest["model"]["serializedFile"]
          model_pt_path = os.path.join(model_dir, serialized_file)
  
      # model def file
      model_file = self.manifest["model"].get("modelFile", "")
  
      if not model_file:
          raise RuntimeError("model.py not specified")
  
      logger.debug("Loading eager model")
      self.model = self._load_pickled_model(
          model_dir, model_file, model_pt_path
      )
  
      self.map_location = (
          "cuda"
          if torch.cuda.is_available()
          and properties.get("gpu_id") is not None
          else "cpu"
      )
  
      self.device = torch.device(
          self.map_location + ":" + str(properties.get("gpu_id"))
          if torch.cuda.is_available()
          and properties.get("gpu_id") is not None
          else self.map_location
      )
  
      self.model.to(self.device)
  
      self.model.eval()
  
      logger.debug("Model file %s loaded successfully", model_pt_path)
  
      self.initialized = True
  
file_path: serve/examples/torchrec_dlrm/dlrm_handler.py
imports: import json
  import logging
  import os
  from abc import ABC
  import torch
  from torchrec.datasets.criteo import DEFAULT_CAT_NAMES
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 1 for calling the TorchRecDLRMHandler obj's underlying member method code with example usage: obj.initialize(context) without return types