docstr: Test loading a signal from a file.
          
docstr_tok: ["Test","loading","a","signal","from","a","file","."]
code: def test_from_file(self, num_channels, channel_selector):
      """Test loading a signal from a file."""
      with tempfile.TemporaryDirectory() as test_dir:
          # Prepare a wav file
          audio_file = os.path.join(test_dir, "audio.wav")
          if num_channels == 1:
              # samples is a one-dimensional vector for single-channel signal
              samples = np.random.rand(self.num_samples)
          else:
              samples = np.random.rand(self.num_samples, num_channels)
          sf.write(audio_file, samples, self.sample_rate, "float")
  
          # Create UUT
          uut = AudioSegment.from_file(
              audio_file, channel_selector=channel_selector
          )
  
          # Create golden reference
          # Note: AudioSegment converts input samples to float32
          golden_samples = select_channels(
              samples.astype("float32"), channel_selector
          )
          expected_num_channels = (
              1 if golden_samples.ndim == 1 else golden_samples.shape[1]
          )
  
          # Test UUT
          assert uut.num_channels == expected_num_channels
          assert uut.num_samples == self.num_samples
          assert uut.sample_rate == self.sample_rate
          assert uut.duration == self.signal_duration_sec
          max_diff = np.max(np.abs(uut.samples - golden_samples))
          assert max_diff < self.max_diff_tol
  
file_path: NeMo/tests/collections/asr/test_preprocessing_segment.py
imports: import json
  import os
  import tempfile
  from typing import List, Type, Union
  import numpy
  import pytest
  import soundfile
  from nemo.collections.asr.parts.preprocessing.perturb import NoisePerturbation, SilencePerturbation
  from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
  from nemo.collections.asr.parts.utils.audio_utils import select_channels
label_desc: Use image node_id 3 for calling the TestAudioSegment obj's underlying member method code with example usage: obj.test_from_file(num_channels, channel_selector) without return types