class_docstr: Base default handler to load torchscript or eager mode [state_dict] models
  Also, provides handle method per torch serve custom model specification
class_docstr_tok: ["Base","default","handler","to","load","torchscript","or","eager","mode","[","state_dict","]","models","Also",",","provides","handle","method","per","torch","serve","custom","model","specification"]
docstr: Loads the pickle file from the given model path.
  
  Args:
      model_dir (str): Points to the location of the model artifacts.
      model_file (.py): the file which contains the model class.
      model_pt_path (str): points to the location of the model pickle file.
  
  Raises:
      RuntimeError: It raises this error when the model.py file is missing.
      ValueError: Raises value error when there is more than one class in the label,
                  since the mapping supports only one label per class.
  
  Returns:
      serialized model file: Returns the pickled pytorch model file
docstr_tok: ["Loads","the","pickle","file","from","the","given","model","path",".","Args",":","model_dir","(","str",")",":","Points","to","the","location","of","the","model","artifacts",".","model_file","(",".py",")",":","the","file","which","contains","the","model","class",".","model_pt_path","(","str",")",":","points","to","the","location","of","the","model","pickle","file",".","Raises",":","RuntimeError",":","It","raises","this","error","when","the","model.py","file","is","missing",".","ValueError",":","Raises","value","error","when","there","is","more","than","one","class","in","the","label",",","since","the","mapping","supports","only","one","label","per","class",".","Returns",":","serialized","model","file",":","Returns","the","pickled","pytorch","model","file"]
code: def _load_pickled_model(self, model_dir, model_file, model_pt_path):
      """
      Loads the pickle file from the given model path.
  
      Args:
          model_dir (str): Points to the location of the model artifacts.
          model_file (.py): the file which contains the model class.
          model_pt_path (str): points to the location of the model pickle file.
  
      Raises:
          RuntimeError: It raises this error when the model.py file is missing.
          ValueError: Raises value error when there is more than one class in the label,
                      since the mapping supports only one label per class.
  
      Returns:
          serialized model file: Returns the pickled pytorch model file
      """
      model_def_path = os.path.join(model_dir, model_file)
      if not os.path.isfile(model_def_path):
          raise RuntimeError("Missing the model.py file")
  
      module = importlib.import_module(model_file.split(".")[0])
      model_class_definitions = list_classes_from_module(module)
      if len(model_class_definitions) != 1:
          raise ValueError(
              "Expected only one class as model definition. {}".format(
                  model_class_definitions
              )
          )
  
      model_class = model_class_definitions[0]
      model = model_class()
      if model_pt_path:
          map_location = (
              None
              if (XLA_AVAILABLE and self.map_location is None)
              else self.device
          )
          state_dict = torch.load(
              model_pt_path, map_location=map_location
          )
          model.load_state_dict(state_dict)
      return model
  
imports: import abc
  import importlib.util
  import logging
  import os
  import time
  import torch
  from pkg_resources import packaging
  from ts.handler_utils.timer import timed
  from ..utils.util import check_valid_pt2_backend, list_classes_from_module, load_label_mapping
label_desc: Use image node_id 5 for calling the BaseHandler obj's underlying member method code with example usage: obj._load_pickled_model(model_dir, model_file, model_pt_path) and returns: model