code: def test_termination_on_last_step(double_wrap):
      # Special case: termination at the last timestep
      # Truncation due to timeout also happens at the same step
  
      env = PendulumEnv()
  
      def patched_step(_action):
          return env.observation_space.sample(), 0.0, True, False, {}
  
      env.step = patched_step
  
      max_episode_length = 1
      env = TimeLimit(env, max_episode_length)
      if double_wrap:
          env = TimeLimit(env, max_episode_length)
      env.reset()
      _, _, terminated, truncated, _ = env.step(
          env.action_space.sample()
      )
      assert terminated is True
      assert truncated is True
  
imports: import pytest
  import gym
  from gym.envs.classic_control.pendulum import PendulumEnv
  from gym.wrappers import TimeLimit
label_desc: Use image node_id 3 for calling a global function with example usage: test_termination_on_last_step(double_wrap) and returns: env,  int,  True,  False,  dict