code: def test_model_fit():
      model = Model(["start_tick", "start_gate"])
  
      dataset = get_dataset()
      loader = DataLoader(dataset, batch_size=1)
  
      initial_loss = 0
      with torch.no_grad():
          for images, targets in loader:
              model._convert_to_int_labels(targets)
              images, targets = model._to_device(images, targets)
              loss_dict = model._model(images, targets)
              total_loss = sum(loss for loss in loss_dict.values())
              initial_loss += total_loss.item()
      initial_loss /= len(loader.dataset)
  
      losses = model.fit(loader, val_dataset=loader, epochs=1)
  
      # Average loss during training should be lower than initial loss
      assert len(losses) == 1
      assert losses[0] < initial_loss
  
      # Should not return anything if not validation losses are produced
      losses = model.fit(loader, loader, epochs=0)
      assert losses is None
  
      # Works when given datasets
      losses = model.fit(dataset, val_dataset=dataset, epochs=1)
      assert len(losses) == 1
  
file_path: detecto/detecto/tests/test_core.py
imports: import torch
  from detecto.core import *
  from detecto.utils import read_image
  from .helpers import get_dataset, get_image, get_model, empty_predictor
  from torchvision import transforms
  from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
label_desc: Use image node_id 5 for calling a global function with example usage: test_model_fit() without return types