def METHOD_NAME(self, inst) -> bool:
    """
    Tries to retrieve a debug name from the source of the instance; sets the
    name of @inst and returns True if available. Otherwise (or if debug mode
    is disabled), returns False.
    """
    if not get_debug_mode():
        return False
    basename = _parse_name(inst)
    if not basename:
        return False
    count = self._name_counter[basename]
    inst.name = basename if count == 0 else f"{basename}_{count}"
    # If this is the first duplicate of basename we've seen (e.g. in a
    # second-iteration of a loop), then we need to rename the first instance
    # with a appended '_0'.
    if count == 1:
        first = self._instance_name_map[basename]
        first.name += "_0"
        del self._instance_name_map[basename]
        self._instance_name_map[first.name] = first
    self._name_counter[basename] += 1
    return True