code: def check_dict_values_same_length(
      head_outputs: dict[str, list[Tensor]],
      keys: list[str] | None = None,
  ) -> None:
      """
      We expect the values in ``head_outputs``: Dict[str, List[Tensor]] to have the same length.
      Will raise ValueError if not.
  
      Args:
          head_outputs: a Dict[str, List[Tensor]] or Dict[str, Tensor]
          keys: the keys in head_output that need to have values (List) with same length.
              If not provided, will use head_outputs.keys().
      """
      if keys is None:
          keys = list(head_outputs.keys())
  
      num_output_levels_list: list[int] = [
          len(head_outputs[k]) for k in keys
      ]
      num_output_levels = torch.unique(
          torch.tensor(num_output_levels_list)
      )
      if len(num_output_levels) != 1:
          raise ValueError(
              f"The values in the input dict should have the same length, Got {num_output_levels_list}."
          )
  
file_path: MONAI/monai/apps/detection/utils/predict_utils.py
imports: from __future__ import annotations
  import torch
  from torch import Tensor, nn
  from monai.inferers import SlidingWindowInferer
label_desc: Use image node_id 2 for calling a global function with example usage: check_dict_values_same_length(head_outputs, keys) without return types