code: def get_wrapper_by_cls(env, cls):
      
      currentenv = env
      while True:
          if isinstance(currentenv, cls):
              return currentenv
          elif isinstance(currentenv, gym.Wrapper):
              currentenv = currentenv.env
          else:
              return None
docs: Returns the gym env wrapper of the given class, or None.