code: def preprocess_manifest(
      dataset_name: str,
      dataset: DatasetMeta,
      min_duration: float,
      max_duration: float,
  ):
      entries = read_manifest(dataset.manifest_path)
      (
          filtered_entries,
          total_hours,
          filtered_hours,
      ) = filter_dataset_by_duration(
          entries=entries,
          min_duration=min_duration,
          max_duration=max_duration,
      )
  
      logging.info(dataset_name)
      logging.info(f"Original # of files: {len(entries)}")
      logging.info(f"Filtered # of files: {len(filtered_entries)}")
      logging.info(f"Original duration: {total_hours:.2f} hours")
      logging.info(f"Filtered duration: {filtered_hours:.2f} hours")
  
      samples = []
      sample_weights = []
      for entry in filtered_entries:
          sample = DatasetSample(
              dataset_name=dataset_name,
              manifest_entry=entry,
              audio_dir=Path(dataset.audio_dir),
          )
          samples.append(sample)
          sample_weights.append(dataset.sample_weight)
  
      return samples, sample_weights
  
imports: import io
  import os
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Dict, List, Optional
  import librosa
  import soundfile
  import torch.utils.data
  import webdataset
  from nemo.collections.asr.data.audio_to_text import expand_sharded_filepaths
  from nemo.collections.asr.parts.preprocessing.segment import available_formats
  from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
  from nemo.collections.tts.parts.preprocessing.feature_processors import FeatureProcessor
  from nemo.collections.tts.parts.utils.tts_dataset_utils import filter_dataset_by_duration, get_weighted_sampler, load_audio, sample_audio, stack_tensors
  from nemo.core.classes import Dataset, IterableDataset
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 2 for calling a global function with example usage: preprocess_manifest(dataset_name, dataset, min_duration, max_duration) and returns: samples,  sample_weights