code: def infer_broadcast_shape(op, shp1, shp2):
      r"""Check the shape validity, and infer the output shape given input shape and operator.
      Note the both :attr:`shp1`, :attr:`shp2` and the returned shape are feature
      shapes (i.e. we remove the first dimension, which correspond to graph statistics
      such as number of nodes, number of edges, etc.).
  
      We allow applying op on operands with different shapes, according to the
      broadcasting semantics of Numpy/Scipy:
      https://numpy.org/doc/stable/user/basics.broadcasting.html
  
      Parameters
      ----------
      op : str
          The binary op's name, could be `add`, `sub`, `mul`, `div`, `dot`, `copy_lhs`, `copy_rhs`.
      shp1 : tuple[int]
          The shape of lhs operand.
      shp2 : tuple[int]
          The shape of rhs operand.
  
      Returns
      -------
      tuple[int]
          shape after broadcasting
      """
      pad_shp1, pad_shp2 = shp1, shp2
      if op == "dot":
          if shp1[-1] != shp2[-1]:
              raise DGLError(
                  "Dot operator is only available for arrays with the "
                  "same size on last dimension, but got {} and {}.".format(
                      shp1, shp2
                  )
              )
      if op == "copy_lhs":
          return shp1
      if op == "copy_rhs":
          return shp2
      # operands are padded to have the same dimensionality with leading 1's.
      if len(shp1) > len(shp2):
          pad_shp2 = (1,) * (len(shp1) - len(shp2)) + shp2
      elif len(shp1) < len(shp2):
          pad_shp1 = (1,) * (len(shp2) - len(shp1)) + shp1
      for d1, d2 in zip(pad_shp1, pad_shp2):
          if d1 != d2 and d1 != 1 and d2 != 1:
              raise DGLError(
                  "Feature shapes {} and {} are not valid for broadcasting.".format(
                      shp1, shp2
                  )
              )
      rst = tuple(max(d1, d2) for d1, d2 in zip(pad_shp1, pad_shp2))
      return rst[:-1] + (1,) if op == "dot" else rst
  
imports: from __future__ import absolute_import
  from .None import backend, ndarray
  from ._ffi.function import _init_api
  from .base import DGLError
label_desc: Use image node_id 1 for calling a global function with example usage: infer_broadcast_shape(op, shp1, shp2) and returns: unknown, shp1, shp2