class_docstr: Backend worker to handle Model Server's python service code
docstr: Expected command
  {
      "command" : "load", string
      "modelPath" : "/path/to/model/file", string
      "modelName" : "name", string
      "gpu" : None if CPU else gpu_id, int
      "handler" : service handler entry point if provided, string
      "envelope" : name of wrapper/unwrapper of request data if provided, string
      "batchSize" : batch size, int
      "limitMaxImagePixels": limit pillow image max_image_pixels, bool
  }
  
  :param load_model_request:
  :return:
docstr_tok: ["Expected","command","{","``","command","''",":","``","load","''",",","string","``","modelPath","''",":","``","\/path\/to\/model\/file","''",",","string","``","modelName","''",":","``","name","''",",","string","``","gpu","''",":","None","if","CPU","else","gpu_id",",","int","``","handler","''",":","service","handler","entry","point","if","provided",",","string","``","envelope","''",":","name","of","wrapper\/unwrapper","of","request","data","if","provided",",","string","``","batchSize","''",":","batch","size",",","int","``","limitMaxImagePixels","''",":","limit","pillow","image","max_image_pixels",",","bool","}",":","param","load_model_request",":",":","return",":"]
code: def load_model(self, load_model_request):
      """
      Expected command
      {
          "command" : "load", string
          "modelPath" : "/path/to/model/file", string
          "modelName" : "name", string
          "gpu" : None if CPU else gpu_id, int
          "handler" : service handler entry point if provided, string
          "envelope" : name of wrapper/unwrapper of request data if provided, string
          "batchSize" : batch size, int
          "limitMaxImagePixels": limit pillow image max_image_pixels, bool
      }
  
      :param load_model_request:
      :return:
      """
      try:
          model_dir = load_model_request["modelPath"].decode("utf-8")
          model_name = load_model_request["modelName"].decode("utf-8")
          handler = (
              load_model_request["handler"].decode("utf-8")
              if load_model_request["handler"]
              else None
          )
          envelope = (
              load_model_request["envelope"].decode("utf-8")
              if "envelope" in load_model_request
              else None
          )
          envelope = (
              envelope
              if envelope is not None and len(envelope) > 0
              else None
          )
  
          batch_size = None
          if "batchSize" in load_model_request:
              batch_size = int(load_model_request["batchSize"])
          logging.info(
              "model_name: %s, batchSize: %d", model_name, batch_size
          )
  
          gpu = None
          if "gpu" in load_model_request:
              gpu = int(load_model_request["gpu"])
  
          limit_max_image_pixels = True
          if "limitMaxImagePixels" in load_model_request:
              limit_max_image_pixels = bool(
                  load_model_request["limitMaxImagePixels"]
              )
  
          self.metrics_cache.model_name = model_name
          model_loader = ModelLoaderFactory.get_model_loader()
          service = model_loader.load(
              model_name,
              model_dir,
              handler,
              gpu,
              batch_size,
              envelope,
              limit_max_image_pixels,
              self.metrics_cache,
          )
  
          logging.debug("Model %s loaded.", model_name)
  
          return service, "loaded model {}".format(model_name), 200
      except MemoryError as ex:
          logging.exception(
              "Load model %s cpu OOM, exception %s", model_name, str(ex)
          )
          return None, "System out of memory", 507
      except RuntimeError as ex:  # pylint: disable=broad-except
          if "CUDA" in str(ex):
              # Handles Case A: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED (Close to OOM) &
              # Case B: CUDA out of memory (OOM)
              logging.exception(
                  "Load model %s cuda OOM, exception %s",
                  model_name,
                  str(ex),
              )
              return None, "System out of memory", 507
          else:
              # Sanity testcases fail without this
              logging.exception(
                  "Failed to load model %s, exception %s",
                  model_name,
                  str(ex),
              )
              return None, "Unknown exception", 500
  
file_path: serve/ts/model_service_worker.py
imports: import logging
  import os
  import platform
  import socket
  import sys
  from typing import Optional
  from ts.arg_parser import ArgParser
  from ts.metrics.metric_cache_yaml_impl import MetricsCacheYamlImpl
  from ts.model_loader import ModelLoaderFactory
  from ts.protocol.otf_message_handler import create_load_model_response, retrieve_msg
label_desc: Use image node_id 2 for calling the TorchModelServiceWorker obj's underlying member method code with example usage: obj.load_model(load_model_request) and returns: service,  str,  int, None,  str,  int, None,  str,  int, None,  str,  int