code: def is_matmul_valid(*args: Union[MatrixExpr, Expr]) -> Boolean:
      """Return the symbolic condition how ``MatMul`` makes sense
  
      Parameters
      ==========
  
      args
          The list of arguments of matrices and scalar expressions to be tested
          for.
  
      Examples
      ========
  
      >>> from sympy import MatrixSymbol, symbols
      >>> from sympy.matrices.expressions._shape import is_matmul_valid
  
      >>> m, n, p, q = symbols('m n p q')
      >>> A = MatrixSymbol('A', m, n)
      >>> B = MatrixSymbol('B', p, q)
      >>> is_matmul_valid(A, B)
      Eq(n, p)
      """
      rows, cols = zip(
          *(arg.shape for arg in args if isinstance(arg, MatrixExpr))
      )
      return And(*(Eq(i, j) for i, j in zip(cols[:-1], rows[1:])))
  
file_path: sympy/sympy/matrices/expressions/_shape.py
imports: from sympy.core.relational import Eq
  from sympy.core.expr import Expr
  from sympy.core.numbers import Integer
  from sympy.logic.boolalg import Boolean, And
  from sympy.matrices.expressions.matexpr import MatrixExpr
  from sympy.matrices.exceptions import ShapeError
  from typing import Union
label_desc: Use image node_id 2 for calling a global function with example usage: is_matmul_valid() and returns: And