code: def raise_not_equal_labels_error(
      first_labels: Dict[str, int],
      second_labels: Dict[str, int],
      first_labels_desc: str,
      second_labels_desc: str,
  ) -> None:
      """
      A helper function for raising comprehensible error if labels from 2 sources are different.
      Such sources may include:
        - labels stored in .nemo checkpoint
        - labels stored in tarred dataset
        - labels passed in config parameters ``model.common_dataset_parameters.{punct_label_ids,capit_label_ids}``
        - labels from files passed in config parameters ``model.class_labels.{punct_labels_file,capit_labels_file}``
        - labels in attributes ``PunctuationCapitalizationModel.{punct_label_ids,capit_label_ids}``
        - any other source
      This function helps to detect configuration early and give error messages that are easy to interpret.
      Call this function if ``first_labels != second_labels``.
  
      Args:
          first_labels: first dictionary with labels
          second_labels: second dictionary with labels
          first_labels_desc: a description of first labels
          second_labels_desc: a description of second labels
      """
      missing_in_first = {
          k: second_labels[k]
          for k in set(second_labels) - set(first_labels)
      }
      missing_in_second = {
          k: first_labels[k]
          for k in set(first_labels) - set(second_labels)
      }
      not_equal = {
          k: {
              "FIRST LABELS": first_labels[k],
              "SECOND LABELS": second_labels[k],
          }
          for k in set(first_labels) & set(second_labels)
          if first_labels[k] != second_labels[k]
      }
      msg = f"{first_labels_desc} (FIRST LABELS) are not equal to {second_labels_desc} (SECOND LABELS)."
      if len(missing_in_first) > 0:
          msg += f" Number of SECOND LABELS missing in the FIRST LABELS: {len(missing_in_first)}."
      if len(missing_in_second) > 0:
          msg += f" Number of FIRST LABELS missing in the SECOND LABELS: {len(missing_in_second)}."
      if len(not_equal) > 0:
          msg += f" Number of labels which are not equal: {len(not_equal)}."
      if len(missing_in_first) > 0:
          msg += (
              f" Several examples of missing SECONDS LABELS in the FIRST LABELS: "
              f"{dict(list(missing_in_first.items())[:3])}."
          )
      if len(missing_in_second) > 0:
          msg += (
              f" Several examples of missing FIRST LABELS in the SECOND LABELS: "
              f"{dict(list(missing_in_second.items())[:3])}."
          )
      if len(not_equal) > 0:
          msg += f" Several examples of labels which are not equal: {dict(list(not_equal.items())[:3])}"
      raise ValueError(msg)
  
imports: import itertools
  import multiprocessing
  import os
  import pickle
  import tempfile
  from dataclasses import dataclass
  from math import ceil
  from pathlib import Path
  from queue import Empty
  from time import sleep
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
  import numpy
  import torch
  from numpy import ndarray
  from omegaconf import MISSING, DictConfig, OmegaConf
  from torch.nn.utils.rnn import pad_sequence
  from tqdm import tqdm
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.collections.nlp.data.data_utils.data_preprocessing import get_label_stats, get_stats
  from nemo.core.classes import Dataset
  from nemo.core.neural_types import AudioSignal, ChannelType, LabelsType, LengthsType, MaskType, NeuralType
  from nemo.utils import logging
  from nemo.utils.get_rank import is_global_rank_zero
label_desc: Use image node_id 10 for calling a global function with example usage: raise_not_equal_labels_error(first_labels, second_labels, first_labels_desc, second_labels_desc) without return types