code: def is_matrix_transpose(x: TensorVariable) -> bool:
      """Check if a variable corresponds to a transpose of the last two axes"""
      node = x.owner
      if (
          node
          and isinstance(node.op, DimShuffle)
          and not (node.op.drop or node.op.augment)
      ):
          [inp] = node.inputs
          ndims = inp.type.ndim
          if ndims < 2:
              return False
          transpose_order = tuple(range(ndims - 2)) + (
              ndims - 1,
              ndims - 2,
          )
          return cast(bool, node.op.new_order == transpose_order)
      return False
  
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 1 for calling a global function with example usage: is_matrix_transpose(x) and returns: False, cast, False