code: def _parse_caption(self, node, state):
          
          if node.tag not in ["caption", "figcaption"]:  # captions used in Tables
              return state
  
          # Add a Caption
          parent = state["parent"][node]
          stable_id = (
              f"{state['document'].name}"
              f"::"
              f"{'caption'}"
              f":"
              f"{state['caption']['idx']}"
          )
  
          # Set name for Section
          name = node.attrib["name"] if "name" in node.attrib else None
  
          if isinstance(parent, Table):
              state["context"][node] = Caption(
                  document=state["document"],
                  table=parent,
                  figure=None,
                  stable_id=stable_id,
                  name=name,
                  position=state["caption"]["idx"],
              )
          elif isinstance(parent, Figure):
              state["context"][node] = Caption(
                  document=state["document"],
                  table=None,
                  figure=parent,
                  stable_id=stable_id,
                  name=name,
                  position=state["caption"]["idx"],
              )
          else:
              raise NotImplementedError("Caption must be a child of Table or Figure.")
          state["caption"]["idx"] += 1
  
          return state
docs: Parse a Caption of the node.
  
          :param node: The lxml node to parse
          :param state: The global state necessary to place the node in context
              of the document as a whole.