docstr: Test SDR calculation with input length.
          
docstr_tok: ["Test","SDR","calculation","with","input","length","."]
code: def test_sdr_input_length(self, num_channels):
      """Test SDR calculation with input length."""
      batch_size = 8
      max_num_samples = 50
      num_batches = 10
      random_seed = 42
      atol = 1e-6
  
      _rng = np.random.default_rng(seed=random_seed)
  
      sdr_loss = SDRLoss()
  
      for n in range(num_batches):
          # Generate random signal
          target = _rng.normal(
              size=(batch_size, num_channels, max_num_samples)
          )
          # Random noise + scaling
          noise = _rng.uniform(low=0.001, high=10) * _rng.normal(
              size=target.shape
          )
          # Estimate
          estimate = target + noise
  
          # Limit calculation to random input_length samples
          input_length = _rng.integers(
              low=1, high=max_num_samples, size=batch_size
          )
  
          # Tensors for testing the loss
          tensor_estimate = torch.tensor(estimate)
          tensor_target = torch.tensor(target)
          tensor_input_length = torch.tensor(input_length)
  
          # Reference SDR
          golden_sdr = 0
          for b, b_len in enumerate(input_length):
              sdr = [
                  calculate_sdr_numpy(
                      estimate=estimate[b, m, :b_len],
                      target=target[b, m, :b_len],
                  )
                  for m in range(num_channels)
              ]
              sdr = np.mean(np.array(sdr))
              golden_sdr += sdr
          golden_sdr /= batch_size  # average over batch
  
          # Calculate SDR
          uut_sdr_loss = sdr_loss(
              estimate=tensor_estimate,
              target=tensor_target,
              input_length=tensor_input_length,
          )
  
          # Compare
          assert np.allclose(
              uut_sdr_loss.cpu().detach().numpy(),
              -golden_sdr,
              atol=atol,
          ), f"SDRLoss not matching for example {n}"
  
file_path: NeMo/tests/collections/asr/test_asr_losses.py
imports: import numpy
  import pytest
  import torch
  from nemo.collections.asr.losses.audio_losses import SDRLoss, calculate_sdr_batch, convolution_invariant_target, scale_invariant_target
  from nemo.collections.asr.parts.utils.audio_utils import calculate_sdr_numpy, convolution_invariant_target_numpy, scale_invariant_target_numpy
label_desc: Use image node_id 3 for calling the TestAudioLosses obj's underlying member method code with example usage: obj.test_sdr_input_length(num_channels) without return types