code: def tf_doc_url(text):
      """Retrieves the TensorFlow doc URL for the given symbol.
  
      Args:
        text: A string for a symbol inside TF (e.g. ``"optimizers.Adam"``).
  
      Returns:
        A string URL linking to the TensorFlow doc site or ``None`` if a URL could
        not be resolved.
      """
      get_tf_name = functools.partial(
          tf_export.get_canonical_name_for_symbol,
          add_prefix_to_v1_names=True,
      )
  
      try:
          prev_symbol = None
          symbol = tf
          for chunk in text.split("."):
              prev_symbol = symbol
              symbol = getattr(prev_symbol, chunk)
      except AttributeError:
          return None
  
      canonical_name = get_tf_name(symbol)
  
      # Check if we're looking at a method reference (e.g. "TensorArray.read").
      if prev_symbol and not canonical_name:
          prev_canonical_name = get_tf_name(prev_symbol)
          if prev_canonical_name:
              canonical_name = (
                  prev_canonical_name + "#" + text.split(".")[-1]
              )
  
      if not canonical_name:
          return None
  
      return urlparse.urljoin(
          TF_API_BASE_URL, canonical_name.replace(".", "/")
      )
  
file_path: sonnet/docs/ext/link_tf_api.py
imports: import functools
  from typing import Any, List, Tuple
  from urllib import parse
  from docutils import nodes
  from docutils.parsers.rst import states
  import tensorflow
  from tensorflow.python.util import tf_export
label_desc: Use image node_id 2 for calling a global function with example usage: tf_doc_url(text) and returns: urlparse, None, None