class_docstr: Helper class that constructs a tarred dataset from scratch, or concatenates tarred datasets
  together and constructs manifests for them.
docstr: Creates a tarball containing the audio files from `entries`.
          
docstr_tok: ["Creates","a","tarball","containing","the","audio","files","from","`","entries","`","."]
code: def _create_shard(
      self, entries, target_dir, shard_id, manifest_folder
  ):
      """Creates a tarball containing the audio files from `entries`."""
      if self.config.sort_in_shards:
          entries.sort(key=lambda x: x["duration"], reverse=False)
  
      new_entries = []
      tar = tarfile.open(
          os.path.join(target_dir, f"audio_{shard_id}.tar"),
          mode="w",
          dereference=True,
      )
  
      count = dict()
      for entry in entries:
          # We squash the filename since we do not preserve directory structure of audio files in the tarball.
          if os.path.exists(entry["audio_filepath"]):
              audio_filepath = entry["audio_filepath"]
          else:
              audio_filepath = os.path.join(
                  manifest_folder, entry["audio_filepath"]
              )
              if not os.path.exists(audio_filepath):
                  raise FileNotFoundError(
                      f"Could not find {entry['audio_filepath']}!"
                  )
  
          base, ext = os.path.splitext(audio_filepath)
          base = base.replace("/", "_")
          # Need the following replacement as long as WebDataset splits on first period
          base = base.replace(".", "_")
          squashed_filename = f"{base}{ext}"
          if squashed_filename not in count:
              self._write_to_tar(tar, audio_filepath, squashed_filename)
              to_write = squashed_filename
              count[squashed_filename] = 1
          else:
              to_write = (
                  base + "-sub" + str(count[squashed_filename]) + ext
              )
              count[squashed_filename] += 1
  
          new_entry = {
              "audio_filepath": to_write,
              "duration": entry["duration"],
              "shard_id": shard_id,  # Keep shard ID for recordkeeping
          }
  
          if "label" in entry:
              new_entry["label"] = entry["label"]
  
          if "text" in entry:
              new_entry["text"] = entry["text"]
  
          if "offset" in entry:
              new_entry["offset"] = entry["offset"]
  
          if "lang" in entry:
              new_entry["lang"] = entry["lang"]
  
          new_entries.append(new_entry)
  
      tar.close()
      return new_entries
  
imports: import argparse
  import copy
  import json
  import os
  import random
  import tarfile
  from collections import defaultdict
  from dataclasses import dataclass, field
  from datetime import datetime
  from io import BytesIO
  from typing import Any, List, Optional
  import numpy
  import soundfile
  from joblib import Parallel, delayed
  from omegaconf import DictConfig, OmegaConf, open_dict
label_desc: Use image node_id 7 for calling the ASRTarredDatasetBuilder obj's underlying member method code with example usage: obj._create_shard(entries, target_dir, shard_id, manifest_folder) and returns: new_entries