code: def lowrank_log_likelihood(
      rank: int, mu: Tensor, D: Tensor, W: Tensor, x: Tensor
  ) -> Tensor:
      F = getF(mu)
  
      dim = F.ones_like(mu).sum(axis=-1).max()
  
      dim_factor = dim * math.log(2 * math.pi)
  
      if W is not None:
          batch_capacitance_tril = capacitance_tril(
              F=F, rank=rank, W=W, D=D
          )
  
          log_det_factor = log_det(
              F=F,
              batch_D=D,
              batch_capacitance_tril=batch_capacitance_tril,
          )
  
          mahalanobis_factor = mahalanobis_distance(
              F=F,
              W=W,
              D=D,
              capacitance_tril=batch_capacitance_tril,
              x=x - mu,
          )
      else:
          log_det_factor = D.log().sum(axis=-1)
          x_centered = x - mu
          mahalanobis_factor = F.broadcast_div(
              x_centered.square(), D
          ).sum(axis=-1)
  
      ll: Tensor = -0.5 * (
          F.broadcast_add(dim_factor, log_det_factor)
          + mahalanobis_factor
      )
  
      return ll
  
imports: import math
  from typing import Optional, Tuple
  import numpy
  from mxnet import gluon
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
  from .distribution import Distribution, _sample_multiple, getF
  from .distribution_output import ArgProj, DistributionOutput, AffineTransformedDistribution
label_desc: Use image node_id 4 for calling a global function with example usage: lowrank_log_likelihood(rank, mu, D, W, x) and returns: ll