code: def log1mexp(x: Tensor) -> Tensor:
      """Numerically accurate evaluation of log(1 - exp(x)) for x < 0.
      See [Maechler2012accurate]_ for details.
      """
      log2 = get_constants_like(values=_log2, ref=x)
      is_small = -log2 < x  # x < 0
      return torch.where(
          is_small,
          (-x.expm1()).log(),
          (-x.exp()).log1p(),
      )
  
imports: from __future__ import annotations
  import math
  from typing import Callable, Tuple, Union
  import torch
  from botorch.exceptions import UnsupportedError
  from botorch.utils.constants import get_constants_like
  from torch import finfo, Tensor
  from torch.nn.functional import softplus
label_desc: Use image node_id 7 for calling a global function with example usage: log1mexp(x) and returns: torch