code: def loop_mmseg(dl, model, losses_stats, device):
      samples_plus_losses = []
  
      model.eval()
  
      with torch.no_grad():
          for data, sample in pbar(dl):
              torch.manual_seed(0)
              _, data = _move_to_device(None, data, device)
              loss = model(**data)
              loss = sum_losses_mmseg(loss)
  
              for l in losses_stats.keys():
                  losses_stats[l].append(loss[l])
  
              loss_comp = LossesRecordComponent()
              loss_comp.set_losses(loss)
              sample[0].add_component(loss_comp)
              sample[0].set_img(mmseg_tensor_to_image(data["img"][0]))
              samples_plus_losses.append(sample[0])
  
      return samples_plus_losses, losses_stats
  
file_path: icevision/icevision/models/mmseg/common/interpretation_utils.py
imports: from icevision.imports import *
  from icevision.utils import *
  from icevision.core import *
  from icevision.data import *
  from icevision.models.interpretation import _move_to_device
  from icevision.core.record_components import LossesRecordComponent
  from icevision.models.mmseg.common.utils import mmseg_tensor_to_image
label_desc: Use image node_id 2 for calling a global function with example usage: loop_mmseg(dl, model, losses_stats, device) and returns: samples_plus_losses,  losses_stats