code: def wrap_with_monitor(env, video_dir):
    
    env = ExtendToEvenDimentions(env)
    env = RenderObservations(env)  # pylint: disable=redefined-variable-type
    env = gym.wrappers.Monitor(env, video_dir, force=True,
                               video_callable=lambda idx: True,
                               write_upon_reset=True)
    return env
docs: Wrap environment with gym.Monitor.
  
    Video recording provided by Monitor requires
      1) both height and width of observation to be even numbers.
      2) rendering of environment
  
    Args:
      env: environment.
      video_dir: video directory.
  
    Returns:
      wrapped environment.