code: def plot_mask_validation_results(
      dataloader,
      class_label_map,
      model_name: str,
      predictor: SegmentationPredictor,
      table: wandb.Table,
      max_validation_batches: int,
      epoch: Optional[int] = None,
  ):
      data_idx = 0
      for batch_idx, batch in enumerate(dataloader):
          for img_idx, image_path in enumerate(batch["im_file"]):
              prediction_result = predictor(image_path)[0]
              (
                  _,
                  prediction_mask_data,
                  prediction_box_data,
                  mean_confidence_map,
              ) = plot_mask_predictions(prediction_result, model_name)
              try:
                  ground_truth_data = get_ground_truth_bbox_annotations(
                      img_idx, image_path, batch, class_label_map
                  )
                  wandb_image = wandb.Image(
                      image_path,
                      boxes={
                          "ground-truth": {
                              "box_data": ground_truth_data,
                              "class_labels": class_label_map,
                          },
                          "predictions": prediction_box_data,
                      },
                      masks=prediction_mask_data,
                  )
                  table_rows = [
                      data_idx,
                      batch_idx,
                      wandb_image,
                      mean_confidence_map,
                      prediction_result.speed,
                  ]
                  table_rows = (
                      [epoch] + table_rows
                      if epoch is not None
                      else table_rows
                  )
                  table_rows = [model_name] + table_rows
                  table.add_data(*table_rows)
                  data_idx += 1
              except TypeError:
                  pass
          if batch_idx + 1 == max_validation_batches:
              break
      return table
  
file_path: wandb/wandb/integration/ultralytics/mask_utils.py
imports: from typing import Dict, Optional, Tuple
  import numpy
  from ultralytics.engine.results import Results
  from ultralytics.models.yolo.segment import SegmentationPredictor
  from ultralytics.utils.ops import scale_image
  import wandb
  from .bbox_utils import get_ground_truth_bbox_annotations, get_mean_confidence_map
label_desc: Use image node_id 4 for calling a global function with example usage: plot_mask_validation_results(dataloader, class_label_map, model_name, predictor, table, max_validation_batches, epoch) and returns: table