code: def _calculate_log_likelihood(
      beta: NDArray[(Any,), Float], model: Model
  ) -> LogLikelihood:
      pi = scipy.special.expit(model.X @ beta + model.offset)
      p = pi * (1 - pi)
      I = model.X.T @ (p[:, None] * model.X)
      _, log_abs_det = np.linalg.slogdet(I)
      unpenalized_log_likelihood = np.sum(
          model.y * np.log(pi) + (1 - model.y) * np.log(1 - pi)
      )
  
      penalty = 0.5 * log_abs_det
      deviance = -2 * (unpenalized_log_likelihood + penalty)
      return LogLikelihood(pi, I, deviance)
  
file_path: glow/python/glow/gwas/approx_firth.py
imports: from typing import Any, Optional
  import numpy
  from dataclasses import dataclass
  import scipy
  from typeguard import typechecked
  from nptyping import Float, NDArray
  from scipy import stats
label_desc: Use image node_id 1 for calling a global function with example usage: _calculate_log_likelihood(beta, model) and returns: LogLikelihood