code: def __init__(
      self,
      primary_model_path,
      p808_model_path,
      use_gpu=False,
      convert_to_torch=False,
  ):
      self.convert_to_torch = convert_to_torch
      self.use_gpu = use_gpu
      if convert_to_torch:
          try:
              from onnx2torch import convert
          except ModuleNotFoundError:
              raise RuntimeError(
                  "Please install onnx2torch manually and retry!"
              )
  
          if primary_model_path is not None:
              self.primary_model = convert(primary_model_path).eval()
              self.p808_model = convert(p808_model_path).eval()
          self.spectrogram = torchaudio.transforms.Spectrogram(
              n_fft=321, hop_length=160, pad_mode="constant"
          )
  
          self.to_db = torchaudio.transforms.AmplitudeToDB(
              "power", top_db=80.0
          )
          if use_gpu:
              if primary_model_path is not None:
                  self.primary_model = self.primary_model.cuda()
                  self.p808_model = self.p808_model.cuda()
              self.spectrogram = self.spectrogram.cuda()
      else:
          try:
              import onnxruntime as ort
          except ModuleNotFoundError:
              raise RuntimeError(
                  "Please install onnxruntime manually and retry!"
              )
  
          prvd = (
              "CUDAExecutionProvider"
              if use_gpu
              else "CPUExecutionProvider"
          )
          if primary_model_path is not None:
              self.onnx_sess = ort.InferenceSession(
                  primary_model_path, providers=[prvd]
              )
              self.p808_onnx_sess = ort.InferenceSession(
                  p808_model_path, providers=[prvd]
              )
  
file_path: espnet/espnet2/enh/layers/dnsmos.py
imports: import json
  import math
  import librosa
  import numpy
  import requests
  import torch
  import torchaudio
label_desc: Use image node_id 1 to create a new DNSMOS_local object  with example: obj = DNSMOS_local(primary_model_path, p808_model_path, use_gpu, convert_to_torch)