code: def remove_unexpected_files_and_dirs(
      output_dir: Path, output_file_tmpl: str, metadata_file_name: Path
  ) -> None:
      """
      This function removes all files with names which may be used in the dataset creation.
  
      Args:
          output_dir: a path to directory where removal is performed
          output_file_tmpl: a format string for a name of final tar file. Must include fields ``ctr`` for number of the
              file and ``num_batches`` for number of batches in the file.
          metadata_file_name: a metadata file name
      """
      if not output_dir.is_dir():
          return
      tar_final_pattern = re.compile(
          output_file_tmpl.format(ctr=NUMBER_RE, num_batches=NUMBER_RE)
      )
      unexpected_tar_files = [
          path
          for path in output_dir.iterdir()
          if any(
              [
                  p.match(path.name) is not None
                  for p in [
                      TAR_FRAGMENT_PATTERN_IN_PROGRESS,
                      TAR_FRAGMENT_PATTERN_FINISHED,
                      TAR_FRAGMENT_PATTERN_TO_REPACK,
                      tar_final_pattern,
                  ]
              ]
          )
      ]
      if unexpected_tar_files:
          logging.warning(
              f"Found {len(unexpected_tar_files)} unexpected tar files in the output directory {output_dir}. "
              f"All of them are going to be removed. The files match one of 3 patterns: "
              f"'{TAR_FRAGMENT_PATTERN_IN_PROGRESS.pattern}', '{TAR_FRAGMENT_PATTERN_FINISHED.pattern}', "
              f"'{tar_final_pattern.pattern}'. The first unexpected files: "
              f"{', '.join([str(f) for f in unexpected_tar_files[:3]])}."
          )
          for fn in unexpected_tar_files:
              fn.unlink()
      if metadata_file_name.exists():
          logging.warning(
              f"Found metadata file {metadata_file_name}. It is going to be removed."
          )
          metadata_file_name.unlink()
      punct_label_ids = output_dir / DEFAULT_PUNCT_LABEL_VOCAB_FILE_NAME
      capit_label_ids = output_dir / DEFAULT_CAPIT_LABEL_VOCAB_FILE_NAME
      if punct_label_ids.exists():
          logging.warning(
              f"Found unexpected punctuation label file {punct_label_ids}. It is going to be removed."
          )
          punct_label_ids.unlink()
      if capit_label_ids.exists():
          logging.warning(
              f"Found unexpected capitalization label file {capit_label_ids}. It is going to be removed."
          )
          capit_label_ids.unlink()
  
imports: import inspect
  import json
  import multiprocessing
  import os
  import pickle
  import re
  import shutil
  import tempfile
  from collections import deque
  from pathlib import Path
  from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
  import numpy
  import torch
  import webdataset
  from joblib import Parallel, delayed
  from omegaconf import DictConfig
  from torch.utils.data import IterableDataset
  from nemo.collections.common.tokenizers import TokenizerSpec
  from nemo.collections.nlp.data.token_classification.punctuation_capitalization_dataset import LABEL_ID_DIR_FOR_NEMO_CHECKPOINT, BertPunctuationCapitalizationDataset, Progress, create_label_ids, create_masks_and_segment_ids, load_label_ids, raise_not_equal_labels_error
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.core.neural_types import AudioSignal, ChannelType, LabelsType, LengthsType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: remove_unexpected_files_and_dirs(output_dir, output_file_tmpl, metadata_file_name) without return types