class_docstr: Base audio dataset.
  
  The dataset takes a list of AudioMeta and create a dataset composed of segments of audio
  and potentially additional information, by creating random segments from the list of audio
  files referenced in the metadata and applying minimal data pre-processing such as resampling,
  mixing of channels, padding, etc.
  
  If no segment_duration value is provided, the AudioDataset will return the full wav for each
  audio file. Otherwise, it will randomly sample audio files and create a segment of the specified
  duration, applying padding if required.
  
  By default, only the torch Tensor corresponding to the waveform is returned. Setting return_info=True
  allows to return a tuple containing the torch Tensor and additional metadata on the segment and the
  original audio meta.
  
  Note that you can call `start_epoch(epoch)` in order to get
  a deterministic "randomization" for `shuffle=True`.
  For a given epoch and dataset index, this will always return the same extract.
  You can get back some diversity by setting the `shuffle_seed` param.
  
  Args:
      meta (list of AudioMeta): List of audio files metadata.
      segment_duration (float, optional): Optional segment duration of audio to load.
          If not specified, the dataset will load the full audio segment from the file.
      shuffle (bool): Set to `True` to have the data reshuffled at every epoch.
      sample_rate (int): Target sample rate of the loaded audio samples.
      channels (int): Target number of channels of the loaded audio samples.
      sample_on_duration (bool): Set to `True` to sample segments with probability
          dependent on audio file duration. This is only used if `segment_duration` is provided.
      sample_on_weight (bool): Set to `True` to sample segments using the `weight` entry of
          `AudioMeta`. If `sample_on_duration` is also True, the actual weight will be the product
          of the file duration and file weight. This is only used if `segment_duration` is provided.
      min_segment_ratio (float): Minimum segment ratio to use when the audio file
          is shorter than the desired segment.
      max_read_retry (int): Maximum number of retries to sample an audio segment from the dataset.
      return_info (bool): Whether to return the wav only or return wav along with segment info and metadata.
      min_audio_duration (float, optional): Minimum audio file duration, in seconds, if provided
          audio shorter than this will be filtered out.
      max_audio_duration (float, optional): Maximal audio file duration in seconds, if provided
          audio longer than this will be filtered out.
      shuffle_seed (int): can be used to further randomize
      load_wav (bool): if False, skip loading the wav but returns a tensor of 0
          with the expected segment_duration (which must be provided if load_wav is False).
      permutation_on_files (bool): only if `sample_on_weight` and `sample_on_duration`
          are False. Will ensure a permutation on files when going through the dataset.
          In that case the epoch number must be provided in order for the model
          to continue the permutation across epochs. In that case, it is assumed
          that `num_samples = total_batch_size * num_updates_per_epoch`, with
          `total_batch_size` the overall batch size accounting for all gpus.
class_docstr_tok: ["Base","audio","dataset",".","The","dataset","takes","a","list","of","AudioMeta","and","create","a","dataset","composed","of","segments","of","audio","and","potentially","additional","information",",","by","creating","random","segments","from","the","list","of","audio","files","referenced","in","the","metadata","and","applying","minimal","data","pre-processing","such","as","resampling",",","mixing","of","channels",",","padding",",","etc",".","If","no","segment_duration","value","is","provided",",","the","AudioDataset","will","return","the","full","wav","for","each","audio","file",".","Otherwise",",","it","will","randomly","sample","audio","files","and","create","a","segment","of","the","specified","duration",",","applying","padding","if","required",".","By","default",",","only","the","torch","Tensor","corresponding","to","the","waveform","is","returned",".","Setting","return_info=True","allows","to","return","a","tuple","containing","the","torch","Tensor","and","additional","metadata","on","the","segment","and","the","original","audio","meta",".","Note","that","you","can","call","`","start_epoch","(","epoch",")","`","in","order","to","get","a","deterministic","``","randomization","''","for","`","shuffle=True","`",".","For","a","given","epoch","and","dataset","index",",","this","will","always","return","the","same","extract",".","You","can","get","back","some","diversity","by","setting","the","`","shuffle_seed","`","param",".","Args",":","meta","(","list","of","AudioMeta",")",":","List","of","audio","files","metadata",".","segment_duration","(","float",",","optional",")",":","Optional","segment","duration","of","audio","to","load",".","If","not","specified",",","the","dataset","will","load","the","full","audio","segment","from","the","file",".","shuffle","(","bool",")",":","Set","to","`","True","`","to","have","the","data","reshuffled","at","every","epoch",".","sample_rate","(","int",")",":","Target","sample","rate","of","the","loaded","audio","samples",".","channels","(","int",")",":","Target","number","of","channels","of","the","loaded","audio","samples",".","sample_on_duration","(","bool",")",":","Set","to","`","True","`","to","sample","segments","with","probability","dependent","on","audio","file","duration",".","This","is","only","used","if","`","segment_duration","`","is","provided",".","sample_on_weight","(","bool",")",":","Set","to","`","True","`","to","sample","segments","using","the","`","weight","`","entry","of","`","AudioMeta","`",".","If","`","sample_on_duration","`","is","also","True",",","the","actual","weight","will","be","the","product","of","the","file","duration","and","file","weight",".","This","is","only","used","if","`","segment_duration","`","is","provided",".","min_segment_ratio","(","float",")",":","Minimum","segment","ratio","to","use","when","the","audio","file","is","shorter","than","the","desired","segment",".","max_read_retry","(","int",")",":","Maximum","number","of","retries","to","sample","an","audio","segment","from","the","dataset",".","return_info","(","bool",")",":","Whether","to","return","the","wav","only","or","return","wav","along","with","segment","info","and","metadata",".","min_audio_duration","(","float",",","optional",")",":","Minimum","audio","file","duration",",","in","seconds",",","if","provided","audio","shorter","than","this","will","be","filtered","out",".","max_audio_duration","(","float",",","optional",")",":","Maximal","audio","file","duration","in","seconds",",","if","provided","audio","longer","than","this","will","be","filtered","out",".","shuffle_seed","(","int",")",":","can","be","used","to","further","randomize","load_wav","(","bool",")",":","if","False",",","skip","loading","the","wav","but","returns","a","tensor","of","0","with","the","expected","segment_duration","(","which","must","be","provided","if","load_wav","is","False",")",".","permutation_on_files","(","bool",")",":","only","if","`","sample_on_weight","`","and","`","sample_on_duration","`","are","False",".","Will","ensure","a","permutation","on","files","when","going","through","the","dataset",".","In","that","case","the","epoch","number","must","be","provided","in","order","for","the","model","to","continue","the","permutation","across","epochs",".","In","that","case",",","it","is","assumed","that","`","num_samples","=","total_batch_size","*","num_updates_per_epoch","`",",","with","`","total_batch_size","`","the","overall","batch","size","accounting","for","all","gpus","."]
docstr: Return the sampling probabilities for each file inside `self.meta`.
docstr_tok: ["Return","the","sampling","probabilities","for","each","file","inside","`","self.meta","`","."]
code: def _get_sampling_probabilities(self, normalized: bool = True):
      """Return the sampling probabilities for each file inside `self.meta`."""
      scores: tp.List[float] = []
      for file_meta in self.meta:
          score = 1.0
          if self.sample_on_weight and file_meta.weight is not None:
              score *= file_meta.weight
          if self.sample_on_duration:
              score *= file_meta.duration
          scores.append(score)
      probabilities = torch.tensor(scores)
      if normalized:
          probabilities /= probabilities.sum()
      return probabilities
  
imports: import argparse
  import copy
  from concurrent.futures import ThreadPoolExecutor, Future
  from dataclasses import dataclass, fields
  from contextlib import ExitStack
  from functools import lru_cache
  import gzip
  import json
  import logging
  import os
  from pathlib import Path
  import random
  import sys
  import typing
  import torch
  import torch.nn.functional
  from .audio import audio_read, audio_info
  from .audio_utils import convert_audio
  from .zip import PathInZip
label_desc: Use image node_id 4 for calling the AudioDataset obj's underlying member method code with example usage: obj._get_sampling_probabilities(normalized) and returns: probabilities