docstr: Tests that trials are represented fairly.
docstr_tok: ["Tests","that","trials","are","represented","fairly","."]
code: def testFairFilterTrials(self):
      """Tests that trials are represented fairly."""
      trials_by_state = collections.defaultdict(list)
      # States for which trials are under and overrepresented
      states_under = (Trial.PAUSED, Trial.ERROR)
      states_over = (Trial.PENDING, Trial.RUNNING, Trial.TERMINATED)
  
      max_trials = 13
      num_trials_under = (
          2  # num of trials for each underrepresented state
      )
      num_trials_over = (
          10  # num of trials for each overrepresented state
      )
  
      i = 0
      for state in states_under:
          for _ in range(num_trials_under):
              trials_by_state[state].append(self.mock_trial(state, i))
              i += 1
      for state in states_over:
          for _ in range(num_trials_over):
              trials_by_state[state].append(self.mock_trial(state, i))
              i += 1
  
      filtered_trials_by_state = _fair_filter_trials(
          trials_by_state, max_trials=max_trials
      )
      for state in trials_by_state:
          if state in states_under:
              expected_num_trials = num_trials_under
          else:
              expected_num_trials = (
                  max_trials - num_trials_under * len(states_under)
              ) / len(states_over)
          state_trials = filtered_trials_by_state[state]
          self.assertEqual(len(state_trials), expected_num_trials)
          # Make sure trials are sorted newest-first within state.
          for i in range(len(state_trials) - 1):
              assert (
                  state_trials[i].trial_id
                  < state_trials[i + 1].trial_id
              )
  
imports: import collections
  import os
  import regex
  import unittest
  from unittest.mock import MagicMock, Mock, patch
  import pytest
  import numpy
  from ray import train, tune
  from ray._private.test_utils import run_string_as_driver
  from ray.tune.progress_reporter import CLIReporter, JupyterNotebookReporter, ProgressReporter, _fair_filter_trials, _best_trial_str, _detect_reporter, _time_passed_str, _trial_progress_str, TuneReporterBase, _max_len
  from ray.tune.result import AUTO_RESULT_KEYS
  from ray.tune.experiment.trial import Trial
label_desc: Use image node_id 3 for calling the ProgressReporterTest obj's underlying member method code with example usage: obj.testFairFilterTrials() without return types