code: def predict_uncertain_helper(
      model: Model,
      batch: torch.LongTensor,
      score_method: Callable[..., torch.FloatTensor],
      num_samples: int,
      slice_size: Optional[int] = None,
      *,
      mode: Optional[InductiveMode],
  ) -> UncertainPrediction:
      """
      Predict with uncertainty estimates via Monte-Carlo dropout.
  
      :param model:
          the model used for predicting scores
      :param batch:
          the batch on which to predict. Its shape and content has to match what
          the `score_method` requires.
      :param score_method:
          the base score method to use (from `score_{hrt,h,r,t}`)
      :param num_samples: >1
          The number of samples to use. More samples lead to better estimates, but
          increase memory requirements and runtime.
      :param slice_size: >0
          The divisor for the scoring function when using slicing.
      :param mode:
          The pass mode, which is None in the transductive setting and one of "training",
          "validation", or "testing" in the inductive setting.
  
      :return:
          A tuple (score_mean, score_std) of the mean and std of the scores sampled
          from the dropout distribution. The std may be interpreted as a measure of
          uncertainty.
  
      :raises MissingDropoutError:
          if the model does not contain dropout layers.
  
      .. warning::
          This function sets the model to evaluation mode and all dropout layers to
          training mode.
      """
      dropout_modules = get_dropout_modules(model)
      if not dropout_modules:
          raise MissingDropoutError(
              "Model needs to contain at least one dropout layer to use the Monte-Carlo Dropout technique.",
          )
  
      # Enforce evaluation mode
      model.eval()
  
      # set dropout layers to training mode
      for module in dropout_modules:
          module.train()
  
      # draw samples
      batch = batch.to(model.device)
      kwargs = {}
      if slice_size is not None:
          kwargs["slice_size"] = slice_size
      scores = torch.stack(
          [
              score_method(batch, mode=mode, **kwargs)
              for _ in range(num_samples)
          ],
          dim=0,
      )
      if model.predict_with_sigmoid:
          scores = torch.sigmoid(scores)
  
      # compute mean and std
      return UncertainPrediction.from_scores(scores)
  
file_path: pykeen/src/pykeen/models/uncertainty.py
imports: from typing import Callable, NamedTuple, Optional
  import torch
  from .base import Model
  from ..typing import InductiveMode
  from ..utils import get_dropout_modules
label_desc: Use image node_id 1 for calling a global function with example usage: predict_uncertain_helper(model, batch, score_method, num_samples, slice_size) and returns: UncertainPrediction