code: def template_choices(templates, display_names=None, suffix=False):
      
      # allow for global template names, as well as usage-local ones.
      if display_names is None:
          display_names = getattr(settings, 'TEMPLATEFINDER_DISPLAY_NAMES', {})
  
      to_space_re = re.compile(r'[^a-zA-Z0-9\-]+')
  
      def fix_display_title(template_path):
          if template_path in display_names:
              return display_names[template_path]
          # take the last part from the template path; works even if there is no /
          lastpart = template_path.rpartition('/')[-1]
          # take everything to the left of the rightmost . (the file extension)
          if suffix:
              lastpart_with_suffix = lastpart
              return capfirst(lastpart_with_suffix)
          else:
              lastpart_minus_suffix = lastpart.rpartition('.')[0]
              # convert most non-alphanumeric characters into spaces, with the
              # exception of hyphens.
              lastpart_spaces = to_space_re.sub(' ', lastpart_minus_suffix)
          return capfirst(lastpart_spaces)
  
      return ((template, fix_display_title(template)) for template in templates)
docs: Given an iterable of `templates`, calculate human-friendly display names
      for each of them, optionally using the `display_names` provided, or a
      global dictionary (`TEMPLATEFINDER_DISPLAY_NAMES`) stored in the Django
      project's settings.
  
      .. note:: As the resulting iterable is a lazy generator, if it needs to be
                consumed more than once, it should be turned into a `set`, `tuple`
                or `list`.
  
      :param list templates: an iterable of template paths, as returned by
                             `find_all_templates`
      :param display_names: If given, should be a dictionary where each key
                            represents a template path in `templates`, and each
                            value is the display text.
      :type display_names: dictionary or None
      :return: an iterable of two-tuples representing value (0) & display text (1)
      :rtype: generator expression