def _evaluate_all_repetitions_on_one_scenario(
    scenario_name: str,
    scenario_config: scenarios_lib.ScenarioConfig,
) -> Sequence[logging_lib.ScenarioResult]:
  """Evaluates the agent on one scenario, averaging over repetitions.

  Args:
    scenario_name: name of the scenario
    scenario_config: config for the scenario
  Returns:
    ScenarioResult object with the results of the evaluation.
  Raises:
    ExceptionGroup: if any of the repetitions raised an exception.
  """
  print(f'Running scenario: {scenario_name}')
  # Run several simulations per scenario
  tasks_this_scenario = {
      str(i): functools.partial(
          _evaluate_one_repetition,
          scenario_name=scenario_name,
          scenario_config=scenario_config,
          repetition_idx=i,
      )
      for i in range(args.num_repetitions_per_scenario)
  }
  outputs_per_repetition, exceptions_per_repetition = (
      concurrency.run_tasks_in_background(
          tasks_this_scenario,
      )
  )
  if exceptions_per_repetition:
    raise ExceptionGroup(
        'Raised errors', list(exceptions_per_repetition.values())
    )

  scenario_results = []
  for repetition_idx, outcome in outputs_per_repetition.items():
    if scenario_config.focal_is_resident:
      focal_scores = list(outcome.resident_scores.values())
      background_scores = list(outcome.visitor_scores.values())
    else:
      focal_scores = list(outcome.visitor_scores.values())
      background_scores = list(outcome.resident_scores.values())
    # Ungrouped scores do not differentiate between focal and background.
    ungrouped_scores = focal_scores + background_scores
    # Calculate per capita scores.
    print(f'\nScores for repetition {repetition_idx}:')
    focal_per_capita_score = np.mean(focal_scores)
    print(f'  Focal per capita score: {focal_per_capita_score}')
    background_per_capita_score = np.mean(background_scores)
    print(f'  Background per capita score: {background_per_capita_score}')
    ungrouped_per_capita_score = np.mean(ungrouped_scores)
    print(f'  Ungrouped per capita score: {ungrouped_per_capita_score}')

    scenario_result_ = logging_lib.ScenarioResult(
        scenario=scenario_name,
        repetition_idx=repetition_idx,
        focal_agent=args.agent_name,
        background_agent=scenario_config.background_agent_module,
        focal_per_capita_score=focal_per_capita_score,
        background_per_capita_score=background_per_capita_score,
        ungrouped_per_capita_score=ungrouped_per_capita_score,
        simulation_outcome=outcome,
        focal_is_resident=scenario_config.focal_is_resident,
        api_type=args.api_type,
        model=args.model_name,
        embedder=args.embedder_name,
        disable_language_model=args.disable_language_model,
        exclude_from_elo_calculation=args.exclude_from_elo_calculation,
    )
    scenario_json_filename = (
        f'{args.agent_name}__{args.model_name}__'
        f'{args.embedder_name}__only__{scenario_name}__{repetition_idx}.json'
    ).replace('/', '_')
    scenario_json_filename = os.path.join(results_dir, scenario_json_filename)
    json_str_ = scenario_result_.to_json()
    with open(scenario_json_filename, 'a', encoding='utf-8') as f:
      f.write(json_str_)
    scenario_results.append(scenario_result_)
  return scenario_results
Evaluates the agent on one scenario, averaging over repetitions.

  Args:
    scenario_name: name of the scenario
    scenario_config: config for the scenario
  Returns:
    ScenarioResult object with the results of the evaluation.
  Raises:
    ExceptionGroup: if any of the repetitions raised an exception.
  
examples/deprecated/modular/launch_concordia_challenge_evaluation.py