Switch that ignores brief ON periods

I want to create a switch (the output_switch) that mirrors an existing switch but which ignores brief on periods of that existing switch (the input_switch) - say periods shorter than 5 seconds.

So:
. If the input_switch turns on and stays on, the output_switch should turn on.
. If the input_switch turns on and 2 secnds later turns off the output_switch should stay off.
. If the input_switch turns off the output switch should turn off immediately.

I feel this aught to be possible as a template switch but I can’t think how it would be coded. Can someone help me please?

template:
  - trigger:
      - platform: state
        entity_id: INPUT_SWITCH
        to: 'on'
        for: '00:00:05'
      - platform: state
        entity_id: INPUT_SWITCH
        to: 'off'
    binary_sensor:
      - name: "OUTPUT_SWITCH"
        state: "{{ states('INPUT_SWITCH') }}"

The same thing can also be achieved with a state-based template sensor instead of a trigger-based template sensor. They each have their own benefits.

template:
  - binary_sensor:
      - name: OUTPUT_SWITCH
        state: "{{ states('INPUT_SWITCH') }}"
        delay_on: "0:00:05"

Thank you Troon and mekaneck both!