code: def train_one_epoch(
      model,
      optimizer,
      data_loader,
      device,
      epoch,
      print_freq,
      scaler=None,
  ):
      model.train()
      metric_logger = MetricLogger(delimiter="  ")
      metric_logger.add_meter(
          "lr", SmoothedValue(window_size=1, fmt="{value:.6f}")
      )
      header = f"Epoch: [{epoch}]"
  
      lr_scheduler = None
      if epoch == 0:
          warmup_factor = 1.0 / 1000
          warmup_iters = min(1000, len(data_loader) - 1)
  
          lr_scheduler = torch.optim.lr_scheduler.LinearLR(
              optimizer,
              start_factor=warmup_factor,
              total_iters=warmup_iters,
          )
  
      # Avalanche: added "*_"
      for images, targets, *_ in metric_logger.log_every(
          data_loader, print_freq, header
      ):
          images = list(image.to(device) for image in images)
          targets = [
              {k: v.to(device) for k, v in t.items()} for t in targets
          ]
          with torch.cuda.amp.autocast(enabled=scaler is not None):
              loss_dict = model(images, targets)
              losses = sum(loss for loss in loss_dict.values())
  
          # reduce losses over all GPUs for logging purposes
          loss_dict_reduced = reduce_dict(loss_dict)
          losses_reduced = sum(
              loss for loss in loss_dict_reduced.values()
          )
  
          loss_value = losses_reduced.item()
  
          if not math.isfinite(loss_value):
              print(f"Loss is {loss_value}, stopping training")
              print(loss_dict_reduced)
              sys.exit(1)
  
          optimizer.zero_grad()
          if scaler is not None:
              scaler.scale(losses).backward()
              scaler.step(optimizer)
              scaler.update()
          else:
              losses.backward()
              optimizer.step()
  
          if lr_scheduler is not None:
              lr_scheduler.step()
  
          metric_logger.update(loss=losses_reduced, **loss_dict_reduced)
          metric_logger.update(lr=optimizer.param_groups[0]["lr"])
  
      return metric_logger
  
file_path: avalanche/examples/tvdetection/engine.py
imports: import math
  import sys
  import time
  import torch
  import torchvision.models.detection.mask_rcnn
  from lvis import LVIS
  from pycocotools.coco import COCO
  from torch.utils.data import Subset
  from avalanche.benchmarks.utils import _make_taskaware_classification_dataset, _taskaware_classification_subset, _concat_taskaware_classification_datasets
  from examples.tvdetection.coco_eval import CocoEvaluator
  from examples.tvdetection.coco_utils import CocoDetection, convert_to_coco_api
  from examples.tvdetection.lvis_eval import LvisEvaluator
  from examples.tvdetection.utils import MetricLogger, SmoothedValue, reduce_dict
label_desc: Use image node_id 1 for calling a global function with example usage: train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq, scaler) and returns: metric_logger