code: def format(self, dt, fmt, locale=None):
          
          if not locale:
              locale = pendulum.get_locale()
  
          locale = Locale.load(locale)
  
          result = self._FORMAT_RE.sub(
              lambda m: m.group(1)
              if m.group(1)
              else m.group(2)
              if m.group(2)
              else self._format_token(dt, m.group(3), locale),
              fmt,
          )
  
          return decode(result)
docs: Formats a DateTime instance with a given format and locale.
  
          :param dt: The instance to format
          :type dt: pendulum.DateTime
  
          :param fmt: The format to use
          :type fmt: str
  
          :param locale: The locale to use
          :type locale: str or Locale or None
  
          :rtype: str