code: def _target_type_for_source(source):
      if source.target_type:
          return _validate_target_type(
              source.target_type, f"source {source.name}"
          )
      if source.resdef.target_type:
          return _validate_target_type(
              source.resdef.target_type,
              f"resource {source.resdef.name}",
          )
      return _default_target_type_for_source(source)
  
imports: import os
  import re
  import logging
  import typing
  from guild import cli
  from guild import resolver
  from guild import resourcedef
  from guild import util
label_desc: Use image node_id 26 for calling a global function with example usage: _target_type_for_source(source) and returns: _default_target_type_for_source, _validate_target_type, _validate_target_type