code: def apply(self, doc):
          
          if not isinstance(doc, Document):
              raise TypeError(
                  "Input Contexts to MentionFigures.apply() must be of type Document"
              )
  
          for figure in doc.figures:
              if self.types is None or any(
                  figure.url.lower().endswith(type) for type in self.types
              ):
                  yield TemporaryFigureMention(figure)
docs: Generate MentionFigures from a Document by parsing all of its Figures.
  
          :param doc: The ``Document`` to parse.
          :type doc: ``Document``
          :raises TypeError: If the input doc is not of type ``Document``.