code: def check_learning_achieved(
      tune_results: "tune.ResultGrid",
      min_value,
      evaluation=False,
      metric: str = "episode_reward_mean",
  ):
      """Throws an error if `min_reward` is not reached within tune_results.
  
      Checks the last iteration found in tune_results for its
      "episode_reward_mean" value and compares it to `min_reward`.
  
      Args:
          tune_results: The tune.Tuner().fit() returned results object.
          min_reward: The min reward that must be reached.
  
      Raises:
          ValueError: If `min_reward` not reached.
      """
      # Get maximum reward of all trials
      # (check if at least one trial achieved some learning)
      recorded_values = [
          (
              row[metric]
              if not evaluation
              else row[f"evaluation/{metric}"]
          )
          for _, row in tune_results.get_dataframe().iterrows()
      ]
      best_value = max(recorded_values)
      if best_value < min_value:
          raise ValueError(f"`{metric}` of {min_value} not reached!")
      print(f"`{metric}` of {min_value} reached! ok")
  
imports: from collections import Counter
  import copy
  import gymnasium
  from gymnasium.spaces import Box, Discrete, MultiDiscrete, MultiBinary
  from gymnasium.spaces import Dict
  from gymnasium.spaces import Tuple
  import inspect
  import logging
  import numpy
  import os
  import pprint
  import random
  import re
  import time
  import tree
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Tuple, Type, Union
  import yaml
  import ray
  from ray import air, tune
  from ray.rllib.env.wrappers.atari_wrappers import is_atari, wrap_deepmind
  from ray.rllib.utils.framework import try_import_jax, try_import_tf, try_import_torch
  from ray.rllib.utils.metrics import DIFF_NUM_GRAD_UPDATES_VS_SAMPLER_POLICY, NUM_ENV_STEPS_SAMPLED, NUM_ENV_STEPS_TRAINED
  from ray.rllib.utils.nested_dict import NestedDict
  from ray.rllib.utils.typing import ResultDict
  from ray.rllib.utils.error import UnsupportedSpaceException
  from ray.tune import CLIReporter, run_experiments
label_desc: Use image node_id 5 for calling a global function with example usage: check_learning_achieved(tune_results, min_value, evaluation, metric) without return types