code: def get_fragment_start_bytes(
      text_file: Path,
      labels_file: Path,
      lines_per_dataset_fragment: int,
      audio_file: Path = None,
  ) -> Union[Tuple[Any, Any, Any, Any], Tuple[Any, Any, Any]]:
      """
      A function for calculating borders of dataset fragments. The function is used to split ``text_file`` and
      ``labels_file`` for processing them in parallel.
  
      Args:
          text_file: a path to a dataset source file
          labels_file: a path to a dataset label file
          lines_per_dataset_fragment: a number of lines in one fragment
          audio_file: a path to a dataset audio file if one needed
  
      Returns:
          num_lines: total number of elements in the dataset (number of lines in ``text_file``` and ``labels_file``)
          text_start_bytes: indices of the first bytes of fragments in ``text_file``
          label_start_bytes: indices of the first bytes of fragments in ``labels_file``
      """
      logging.info(
          f"Counting lines in files {text_file} and {labels_file} and creating segment borders. This may take "
          f"considerable time. 86GB, 1.27b lines file was processed in 7 minutes."
      )
      if audio_file:
          result = Parallel(n_jobs=3)(
              delayed(count_lines_and_get_fragment_starting_positions)(
                  file_name, lines_per_dataset_fragment
              )
              for file_name in [text_file, labels_file, audio_file]
          )
          num_lines = result[0][0]
          if result[0][0] != result[1][0]:
              raise ValueError(
                  f"Text file {text_file} and label file {labels_file} contain different number of lines. Number of lines "
                  f"in text file: {result[0][0]}, number of lines in label file: {result[1][0]}."
              )
          text_start_bytes, label_start_bytes, manifest_start_bytes = (
              result[0][1],
              result[1][1],
              result[2][1],
          )
          assert (
              len(text_start_bytes)
              == len(label_start_bytes)
              == len(manifest_start_bytes)
          )
          return (
              num_lines,
              text_start_bytes,
              label_start_bytes,
              manifest_start_bytes,
          )
      else:
          result = Parallel(n_jobs=2)(
              delayed(count_lines_and_get_fragment_starting_positions)(
                  file_name, lines_per_dataset_fragment
              )
              for file_name in [text_file, labels_file]
          )
          num_lines = result[0][0]
          if result[0][0] != result[1][0]:
              raise ValueError(
                  f"Text file {text_file} and label file {labels_file} contain different number of lines. Number of lines "
                  f"in text file: {result[0][0]}, number of lines in label file: {result[1][0]}."
              )
          text_start_bytes, label_start_bytes = (
              result[0][1],
              result[1][1],
          )
          assert len(text_start_bytes) == len(label_start_bytes)
          return num_lines, text_start_bytes, label_start_bytes
  
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 2 for calling a global function with example usage: get_fragment_start_bytes(text_file, labels_file, lines_per_dataset_fragment, audio_file) and returns: num_lines,  text_start_bytes,  label_start_bytes,  manifest_start_bytes, num_lines,  text_start_bytes,  label_start_bytes