Passing Twig Variable into Template from Include?
I suggest using macro (and switch tag instead of if).

{% macro ratio(block) %}
{% spaceless %}
    {% switch block.imageRatio %}
        {% case "thumb" %}
            imageVariantsThumb
        {% case "16by9" %}
            imageVariants16by9
        {% case "3by2" %}
            imageVariants3by2
    {% endswitch %}
{% endspaceless %}    
{% endmacro %}


Macro would be used like this:

{% import 'macro' as macroRatio %}
{% set imageRatio = macroRatio.ratio(block)|trim %}