code: def link_regression(
      output_dim: int = 1,
      clip_limits: Optional[Tuple[float]] = None,
      edge_embedding_method: AnyStr = "ip",
  ):
      """
      Defines a function that predicts a numeric edge regression output vector/scalar from
      (source, destination) node embeddings (node features).
  
      This function takes as input as either:
  
       * A list of two tensors of shape (N, M) being the embeddings for each of the nodes in the link,
         where N is the number of links, and M is the node embedding size.
       * A single tensor of shape (..., N, 2, M) where the axis second from last indexes the nodes
         in the link and N is the number of links and M the embedding size.
  
      Note that the output tensor is flattened before being returned.
  
      .. seealso::
  
         Example using this function: `HinSAGE link prediction <https://stellargraph.readthedocs.io/en/stable/demos/link-prediction/hinsage-link-prediction.html>`__.
  
         Related functionality: :class:`.LinkEmbedding`, :func:`.link_inference`, :func:`.link_classification`.
  
      Args:
          output_dim (int): Number of classifier's output units -- desired dimensionality of the output,
          clip_limits (tuple): lower and upper thresholds for LeakyClippedLinear unit on top. If None (not provided),
              the LeakyClippedLinear unit is not applied.
          edge_embedding_method (str), optional: Name of the method of combining ``(src,dst)`` node features/embeddings into edge embeddings.
              One of:
  
              * ``concat`` -- concatenation,
              * ``ip`` or ``dot`` -- inner product, :math:`ip(u,v) = sum_{i=1..d}{u_i*v_i}`,
              * ``mul`` or ``hadamard`` -- element-wise multiplication, :math:`h(u,v)_i = u_i*v_i`,
              * ``l1`` -- L1 operator, :math:`l_1(u,v)_i = |u_i-v_i|`,
              * ``l2`` -- L2 operator, :math:`l_2(u,v)_i = (u_i-v_i)^2`,
              * ``avg`` -- average, :math:`avg(u,v) = (u+v)/2`.
  
      Returns:
          Function taking edge tensors with ``src``, ``dst`` node embeddings (i.e., pairs of ``(node_src, node_dst)`` tensors) and
          returning a numeric value (e.g., edge attribute being predicted) constructed according to edge_embedding_method.
      """
  
      edge_function = link_inference(
          output_dim=output_dim,
          output_act="linear",
          edge_embedding_method=edge_embedding_method,
          clip_limits=clip_limits,
          name="link_regression",
      )
  
      return edge_function
  
file_path: stellargraph/stellargraph/layer/link_inference.py
imports: from typing import AnyStr, Optional, List, Tuple
  import tensorflow
  from tensorflow.keras.layers import Layer, Concatenate, Dense, Lambda, Multiply, Average, Reshape, Activation
  from tensorflow.keras import backend
  import warnings
label_desc: Use image node_id 3 for calling a global function with example usage: link_regression(output_dim, clip_limits, edge_embedding_method) and returns: edge_function