code: def segment_batch(
      batch,
      segment_length=44100,
      segment_hop_size=22050,
      min_segment_length=22050,
  ):
      all_segments = []
      segment_indices = []
      si = 0
      for bidx in range(len(batch["audio"])):
          audio = batch["audio"][bidx]
          audio_length = batch["audio_len"][bidx]
          audio_actual = audio[:audio_length]
          audio_segments = segment_wav(
              audio_actual,
              segment_length,
              segment_hop_size,
              min_segment_length,
          )
          all_segments += audio_segments
          segment_indices.append((si, si + len(audio_segments) - 1))
          si += len(audio_segments)
  
      return torch.stack(all_segments), segment_indices
  
imports: import argparse
  import json
  import os
  import time
  from multiprocessing import Pool
  from pathlib import Path
  import hydra.utils
  import librosa
  import numpy
  import torch
  from omegaconf import open_dict
  from tqdm import tqdm
  from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
  from nemo.collections.tts.models import ssl_tts
  from nemo.collections.tts.parts.utils.tts_dataset_utils import get_base_dir
  from nemo.core.classes import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: segment_batch(batch, segment_length, segment_hop_size, min_segment_length) and returns: torch,  segment_indices