code: def bernoulli_action_log_prob(logit, action):
      """Calculate the log p of an action with respect to a Bernoulli
      distribution. Use logit rather than prob for numerical stability.
      """
      if action == 0:
          return F.logsigmoid(-logit)
      else:
          return F.logsigmoid(logit)
  
imports: from functools import partial
  import dgl
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.distributions import Bernoulli, Categorical
label_desc: Use image node_id 1 for calling a global function with example usage: bernoulli_action_log_prob(logit, action) and returns: F, F