code: def _total_variation_compute(
      score: Tensor,
      num_elements: Union[int, Tensor],
      reduction: Optional[Literal["mean", "sum", "none"]],
  ) -> Tensor:
      """Compute final total variation score."""
      if reduction == "mean":
          return score.sum() / num_elements
      if reduction == "sum":
          return score.sum()
      if reduction is None or reduction == "none":
          return score
      raise ValueError(
          "Expected argument `reduction` to either be 'sum', 'mean', 'none' or None"
      )
  
imports: from typing import Optional, Tuple, Union
  from torch import Tensor
  from typing_extensions import Literal
label_desc: Use image node_id 2 for calling a global function with example usage: _total_variation_compute(score, num_elements, reduction) and returns: unknown, score, score