class_docstr: Class that processes an example from Audio collection and returns
  a dictionary with prepared signals.
  
  For example, the output dictionary may be the following
  ```
  {
      'input_signal': input_signal_tensor,
      'target_signal': target_signal_tensor,
      'reference_signal': reference_signal_tensor,
      'embedding_vector': embedding_vector
  }
  ```
  Keys in the output dictionary are ordered with synchronous signals given first,
  followed by asynchronous signals and embedding.
  
  Args:
      sample_rate: sample rate used for all audio signals
      random_offset: If `True`, offset will be randomized when loading a subsegment
                     from a file.
class_docstr_tok: ["Class","that","processes","an","example","from","Audio","collection","and","returns","a","dictionary","with","prepared","signals",".","For","example",",","the","output","dictionary","may","be","the","following","``","`","{","'input_signal","'",":","input_signal_tensor",",","'target_signal","'",":","target_signal_tensor",",","'reference_signal","'",":","reference_signal_tensor",",","'embedding_vector","'",":","embedding_vector","}","``","`","Keys","in","the","output","dictionary","are","ordered","with","synchronous","signals","given","first",",","followed","by","asynchronous","signals","and","embedding",".","Args",":","sample_rate",":","sample","rate","used","for","all","audio","signals","random_offset",":","If","`","True","`",",","offset","will","be","randomized","when","loading","a","subsegment","from","a","file","."]
docstr: Get a segment of samples from a single audio file.
  
  Args:
      audio_file: path to an audio file
      sample_rate: sample rate of the loaded samples
      offset: fixed offset in seconds
      num_samples: Optional, number of samples to load.
                   If `None`, all available samples will be loaded.
      channel_selector: Select a subset of available channels.
  
  Returns:
     An array with shape (samples,) or (channels, samples) 
code: def get_segment_from_file(
      audio_file: str,
      sample_rate: int,
      offset: float,
      num_samples: Optional[int] = None,
      channel_selector: Optional[ChannelSelectorType] = None,
  ) -> np.ndarray:
      """Get a segment of samples from a single audio file.
  
      Args:
          audio_file: path to an audio file
          sample_rate: sample rate of the loaded samples
          offset: fixed offset in seconds
          num_samples: Optional, number of samples to load.
                       If `None`, all available samples will be loaded.
          channel_selector: Select a subset of available channels.
  
      Returns:
         An array with shape (samples,) or (channels, samples)
      """
      if num_samples is None:
          segment = AudioSegment.from_file(
              audio_file=audio_file,
              target_sr=sample_rate,
              offset=offset,
              channel_selector=channel_selector,
          )
  
      else:
          segment = AudioSegment.segment_from_file(
              audio_file=audio_file,
              target_sr=sample_rate,
              n_segments=num_samples,
              offset=offset,
              channel_selector=channel_selector,
          )
  
      if segment.samples.ndim == 1:
          # Single-channel signal
          return segment.samples
      elif segment.samples.ndim == 2:
          # Use multi-channel format as (channels, samples)
          return segment.samples.T
      else:
          raise RuntimeError(
              f"Unexpected samples shape: {segment.samples.shape}"
          )
  
imports: import abc
  import math
  import random
  from collections import OrderedDict, namedtuple
  from dataclasses import dataclass
  from typing import Callable, Dict, List, Optional, Tuple, Type, Union
  import librosa
  import numpy
  import torch
  from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
  from nemo.collections.asr.parts.utils.audio_utils import ChannelSelectorType
  from nemo.collections.common.parts.preprocessing import collections
  from nemo.collections.common.parts.utils import flatten
  from nemo.core.classes import Dataset
  from nemo.core.neural_types import AudioSignal, EncodedRepresentation, LengthsType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 20 for calling the ASRAudioProcessor obj's underlying member method code with example usage: obj.get_segment_from_file(audio_file, sample_rate, offset, num_samples, channel_selector) and returns: segment, segment