code: def get_wrapper_by_cls(env, cls):
      """Returns the gym env wrapper of the given class, or None."""
      currentenv = env
      while True:
          if isinstance(currentenv, cls):
              return currentenv
          elif isinstance(currentenv, gym.Wrapper):
              currentenv = currentenv.env
          else:
              return None
  
imports: from collections import deque
  import gymnasium
  from gymnasium import spaces
  import numpy
  from typing import Union
  from ray.rllib.utils.annotations import PublicAPI
  from ray.rllib.utils.images import rgb2gray, resize
label_desc: Use image node_id 2 for calling a global function with example usage: get_wrapper_by_cls(env, cls) and returns: currentenv, None