code: def test_selection_rate_weighted():
      y_true = [0, 0, 0, 0, 0, 0, 0, 0]
      y_pred = [0, 1, 1, 0, 0, 0, 0, 0]
      weight = [1, 2, 3, 4, 1, 2, 1, 2]
  
      result = metrics.selection_rate(
          y_true, y_pred, sample_weight=weight
      )
  
      assert result == 0.3125
  
imports: import pytest
  import fairlearn.metrics
  from fairlearn.metrics._base_metrics import _EMPTY_INPUT_PREDICTIONS_ERROR_MESSAGE
label_desc: Use image node_id 4 for calling a global function with example usage: test_selection_rate_weighted() without return types