code: def max_logprob_discrete(op, values, base_rv, **kwargs):
      r"""Compute the log-likelihood graph for the `Max` operation.
  
      The formula that we use here is :
      .. math::
          \ln(P_{(n)}(x)) = \ln(F(x)^n - F(x-1)^n)
      where $P_{(n)}(x)$ represents the p.m.f of the maximum statistic and $F(x)$ represents the c.d.f of the i.i.d. variables.
      """
      (value,) = values
      logcdf = _logcdf_helper(base_rv, value)
      logcdf_prev = _logcdf_helper(base_rv, value - 1)
  
      [n] = constant_fold([base_rv.size])
  
      logprob = logdiffexp(n * logcdf, n * logcdf_prev)
  
      return logprob
  
imports: from typing import List, Optional
  import pytensor.tensor
  from pytensor.graph.basic import Node
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.rewriting.basic import node_rewriter
  from pytensor.scalar.basic import Mul
  from pytensor.tensor.basic import get_underlying_scalar_constant_value
  from pytensor.tensor.elemwise import Elemwise
  from pytensor.tensor.exceptions import NotScalarConstantError
  from pytensor.tensor.math import Max
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.variable import TensorVariable
  from pymc.logprob.abstract import MeasurableVariable, _logcdf_helper, _logprob, _logprob_helper
  from pymc.logprob.rewriting import measurable_ir_rewrites_db
  from pymc.math import logdiffexp
  from pymc.pytensorf import constant_fold
label_desc: Use image node_id 3 for calling a global function with example usage: max_logprob_discrete(op, values, base_rv) and returns: logprob