code: def _hasattr(obj, attr_name):
      # If possible, avoid retrieving the attribute as the object might run some
      # lazy computation in it.
      if attr_name in dir(obj):
          return True
      try:
          getattr(obj, attr_name)
      except AttributeError:
          return False
      else:
          return True
  
file_path: addons/tensorflow_addons/utils/keras_utils.py
imports: import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: _hasattr(obj, attr_name) and returns: True, True, False