code: def validate_model_goal_function_compatibility(
      goal_function_class, model_class
  ):
      """Determines if ``model_class`` is task-compatible with
      ``goal_function_class``.
  
      For example, a text-generative model like one intended for
      translation or summarization would not be compatible with a goal
      function that requires probability scores, like the
      UntargetedGoalFunction.
      """
      # Verify that this is a valid goal function.
      try:
          matching_model_globs = MODELS_BY_GOAL_FUNCTION[
              goal_function_class
          ]
      except KeyError:
          matching_model_globs = []
          logger.warn(
              f"No entry found for goal function {goal_function_class}."
          )
      # Get options for this goal function.
      # model_module = model_class.__module__
      model_module_path = ".".join(
          (model_class.__module__, model_class.__name__)
      )
      # Ensure the model matches one of these options.
      for glob in matching_model_globs:
          if re.match(glob, model_module_path):
              logger.info(
                  f"Goal function {goal_function_class} compatible with model {model_class.__name__}."
              )
              return
      # If we got here, the model does not match the intended goal function.
      for goal_functions, globs in MODELS_BY_GOAL_FUNCTIONS.items():
          for glob in globs:
              if re.match(glob, model_module_path):
                  logger.warn(
                      f"Unknown if model {model_class.__name__} compatible with provided goal function {goal_function_class}."
                      f" Found match with other goal functions: {goal_functions}."
                  )
                  return
      # If it matches another goal function, warn user.
  
      # Otherwise, this is an unknown model–perhaps user-provided, or we forgot to
      # update the corresponding dictionary. Warn user and return.
      logger.warn(
          f"Unknown if model of class {model_class} compatible with goal function {goal_function_class}."
      )
  
file_path: TextAttack/textattack/shared/validators.py
imports: import re
  import textattack
  from textattack.goal_functions import InputReduction, MinimizeBleu, NonOverlappingOutput, TargetedClassification, UntargetedClassification
  from .None import logger
label_desc: Use image node_id 1 for calling a global function with example usage: validate_model_goal_function_compatibility(goal_function_class, model_class) without return types