code: def _compute_error(
      model: Module,
      pruned_model: Module,
      eval_input_data: DataManager,
      metric: Callable,
  ) -> float:
      if len(eval_input_data) == 0:
          return np.inf
      metric_val = 0.0
      model.eval()
      pruned_model.eval()
      for inputs, y in eval_input_data:
          if torch.cuda.is_available():
              inputs = tuple(data.cuda() for data in inputs)
              pruned_model.cuda()
              model.cuda()
          model_pred = model(*inputs)
          pruned_pred = pruned_model(*inputs)
          metric_val += metric(model_pred, pruned_pred, y)
      return metric_val / len(eval_input_data)
  
imports: import json
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Callable, Dict
  import numpy
  from loguru import logger
  from nebullvm.operations.optimizations.compressors.base import Compressor
  from nebullvm.optional_modules.torch import torch, Module
  from nebullvm.tools.data import DataManager
  from nebullvm.tools.pytorch import save_with_torch_fx, load_with_torch_fx
  from nebullvm.tools.venv import run_in_different_venv
label_desc: Use image node_id 2 for calling the SparseMLCompressor obj's underlying member method code with example usage: obj._compute_error(model, pruned_model, eval_input_data, metric) and returns: unknown, np