code: def get_detector(
      trained_model,
      backbone="resnet18",
      device="cpu",
      quantize=True,
      cudnn_benchmark=False,
  ):
      """
      A wrapper to initialize DBNet text detection model
  
      Parameters
      ----------
      trained_model : str
          Path to trained weight to use.
      backbone : str
          Backbone to use. Options are 'resnet18' or 'resnet50'. The default is 'resnet18'.
      device : str, optional
          Device to use. Options are "cpu" and "cuda". The default is 'cpu'.
      quantize : boolean, optional
          If use, apply model quantization method to the model. The default is True.
      cudnn_benchmark : boolen, optional
          DESCRIPTION. The default is False.
  
      Returns
      -------
      dbnet : obj
          DBNet text detection object.
      """
      dbnet = DBNet(
          initialize_model=False,
          dynamic_import_relative_path=os.path.join("easyocr", "DBNet"),
          device=device,
          verbose=0,
      )
      if backbone not in ["resnet18", "resnet50"]:
          raise ValueError(
              "Invalid backbone. Options are 'resnet18' or 'resnet50'."
          )
      dbnet.initialize_model(
          dbnet.configs[backbone]["model"], trained_model
      )
      if torch.device(device).type == "cpu":
          if quantize:
              try:
                  torch.quantization.quantize_dynamic(
                      dbnet, dtype=torch.qint8, inplace=True
                  )
              except:
                  pass
      else:
          dbnet.model = torch.nn.DataParallel(dbnet.model).to(device)
          cudnn.benchmark = cudnn_benchmark
  
      dbnet.model.eval()
  
      return dbnet
  
imports: import os
  import numpy
  import torch
  import torch.backends.cudnn
  from .DBNet.DBNet import DBNet
label_desc: Use image node_id 2 for calling a global function with example usage: get_detector(trained_model, backbone, device, quantize, cudnn_benchmark) and returns: dbnet