code: def remove_time_limit_wrapper(env):
    
    if isinstance(env, gym.wrappers.TimeLimit):
      env = env.env
    env_ = env
    while isinstance(env_, gym.Wrapper):
      if isinstance(env_, gym.wrappers.TimeLimit):
        raise ValueError("Can remove only top-level TimeLimit gym.Wrapper.")
      env_ = env_.env
    return env
docs: Removes top level TimeLimit Wrapper.
  
    Removes TimeLimit Wrapper from top level if exists, throws error if any other
    TimeLimit Wrapper is present in stack.
  
    Args:
      env: environment
  
    Returns:
      the env with removed time limit wrapper.