code: def add_target(self, ret: list[Node]) -> None:
      node = cast(nodes.math_block, ret[0])
  
      # assign label automatically if math_number_all enabled
      if node["label"] == "" or (
          self.config.math_number_all and not node["label"]
      ):
          seq = self.env.new_serialno("sphinx.ext.math#equations")
          node["label"] = "%s:%d" % (self.env.docname, seq)
  
      # no targets and numbers are needed
      if not node["label"]:
          return
  
      # register label to domain
      domain = cast(MathDomain, self.env.get_domain("math"))
      domain.note_equation(
          self.env.docname, node["label"], location=node
      )
      node["number"] = domain.get_equation_number_for(node["label"])
  
      # add target node
      node_id = make_id("equation-%s" % node["label"])
      target = nodes.target("", "", ids=[node_id])
      self.state.document.note_explicit_target(target)
      ret.insert(0, target)
  
imports: from __future__ import annotations
  import os
  from os import path
  from typing import TYPE_CHECKING, Any, cast
  from docutils import nodes
  from docutils.nodes import Node, make_id
  from docutils.parsers.rst import directives
  from docutils.parsers.rst.directives import images, tables
  from docutils.parsers.rst.directives.misc import Meta
  from docutils.parsers.rst.roles import set_classes
  from sphinx.directives import optional_int
  from sphinx.domains.math import MathDomain
  from sphinx.locale import __
  from sphinx.util import logging
  from sphinx.util.docutils import SphinxDirective
  from sphinx.util.nodes import set_source_info
  from sphinx.util.osutil import SEP, os_path, relpath
label_desc: Use image node_id 2 for calling the MathDirective obj's underlying member method code with example usage: obj.add_target(ret) without return types