code: def local_log_prod_sqr(fgraph, node):
      """
      This utilizes a boolean `positive` tag on matrices.
      """
      (x,) = node.inputs
      if x.owner and isinstance(x.owner.op, Prod):
          # we cannot always make this substitution because
          # the prod might include negative terms
          p = x.owner.inputs[0]
  
          # p is the matrix we're reducing with prod
          if getattr(p.tag, "positive", None) is True:
              return [log(p).sum(axis=x.owner.op.axis)]
  
imports: import logging
  from typing import cast
  from pytensor.graph.rewriting.basic import copy_stack_trace, node_rewriter
  from pytensor.tensor.basic import TensorVariable, diagonal, swapaxes
  from pytensor.tensor.blas import Dot22
  from pytensor.tensor.blockwise import Blockwise
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.math import Dot, Prod, _matrix_matrix_matmul, log, prod
  from pytensor.tensor.nlinalg import MatrixInverse, det
  from pytensor.tensor.rewriting.basic import register_canonicalize, register_specialize, register_stabilize
  from pytensor.tensor.slinalg import Cholesky, Solve, SolveBase, cholesky, solve, solve_triangular
label_desc: Use image node_id 11 for calling a global function with example usage: local_log_prod_sqr(fgraph, node) and returns: list