code: def load_model(self):
      import torch
  
      from sahi.utils.torchvision import MODEL_NAME_TO_CONSTRUCTOR
  
      # read config params
      model_name = None
      num_classes = None
      if self.config_path is not None:
          import yaml
  
          with open(self.config_path, "r") as stream:
              try:
                  config = yaml.safe_load(stream)
              except yaml.YAMLError as exc:
                  raise RuntimeError(exc)
  
          model_name = config.get("model_name", None)
          num_classes = config.get("num_classes", None)
  
      # complete params if not provided in config
      if not model_name:
          model_name = "fasterrcnn_resnet50_fpn"
          logger.warning(
              f"model_name not provided in config, using default model_type: {model_name}'"
          )
      if num_classes is None:
          logger.warning(
              "num_classes not provided in config, using default num_classes: 91"
          )
          num_classes = 91
      if self.model_path is None:
          logger.warning(
              "model_path not provided in config, using pretrained weights and default num_classes: 91."
          )
          pretrained = True
          num_classes = 91
      else:
          pretrained = False
  
      # load model
      model = MODEL_NAME_TO_CONSTRUCTOR[model_name](
          num_classes=num_classes, pretrained=pretrained
      )
      try:
          model.load_state_dict(torch.load(self.model_path))
      except Exception as e:
          TypeError(
              "model_path is not a valid torchvision model path: ", e
          )
  
      self.set_model(model)
  
file_path: sahi/sahi/models/torchvision.py
imports: import logging
  from typing import Any, Dict, List, Optional
  import numpy
  from sahi.models.base import DetectionModel
  from sahi.prediction import ObjectPrediction
  from sahi.utils.import_utils import check_requirements
label_desc: Use image node_id 2 for calling the TorchVisionDetectionModel obj's underlying member method code with example usage: obj.load_model() without return types