code: def safemax(iterable, default=0):
      """Safer variant of ``max()`` that returns a default value if the iterable
      is empty.
  
      Example:
  
          >>> safemax([-5, 6, 4])
          6
          >>> safemax([])
          0
          >>> safemax((), 2)
          2
      """
      it = iter(iterable)
      try:
          first = next(it)
      except StopIteration:
          return default
      else:
          return max(chain([first], it))
  
imports: from contextlib import contextmanager
  from collections.abc import MutableMapping
  from itertools import chain
  from warnings import warn
  import os
  import tempfile
label_desc: Use image node_id 7 for calling a global function with example usage: safemax(iterable, default) and returns: max, default