code: def _expand_variables(input_str, cmake_vars):
      """Expands ${VARIABLE}s and @VARIABLE@s in 'input_str', using dictionary 'cmake_vars'.
  
      Args:
        input_str: the string containing ${VARIABLE} or @VARIABLE@ expressions to expand.
        cmake_vars: a dictionary mapping variable names to their values.
  
      Returns:
        The expanded string.
      """
  
      def replace(match):
          if match.group(1) in cmake_vars:
              return cmake_vars[match.group(1)]
          return ""
  
      return _CMAKE_ATVAR_REGEX.sub(
          replace, _CMAKE_VAR_REGEX.sub(replace, input_str)
      )
  
imports: import re
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: _expand_variables(input_str, cmake_vars) and returns: _CMAKE_ATVAR_REGEX, str, cmake_vars