code: def riemann_builders(
      method: Riemann = Riemann.trapezoid,
  ) -> Tuple[
      Callable[[int], List[float]], Callable[[int], List[float]]
  ]:
      r"""Step sizes are identical and alphas are scaled in [0, 1]
  
      Args:
  
           method (Riemann): `left`, `right`, `middle` and `trapezoid` riemann
  
      Returns:
          2-element tuple of **step_sizes**, **alphas**:
          - **step_sizes** (*Callable*):
                      `step_sizes` takes the number of steps as an
                      input argument and returns an array of steps sizes which
                      sum is smaller than or equal to one.
  
          - **alphas** (*Callable*):
                      `alphas` takes the number of steps as an input argument
                      and returns the multipliers/coefficients for the inputs
                      of integrand in the range of [0, 1]
  
      """
  
      def step_sizes(n: int) -> List[float]:
          assert n > 1, "The number of steps has to be larger than one"
          deltas = [1 / n] * n
          if method == Riemann.trapezoid:
              deltas[0] /= 2
              deltas[-1] /= 2
          return deltas
  
      def alphas(n: int) -> List[float]:
          assert n > 1, "The number of steps has to be larger than one"
          if method == Riemann.trapezoid:
              return torch.linspace(0, 1, n).tolist()
          elif method == Riemann.left:
              return torch.linspace(0, 1 - 1 / n, n).tolist()
          elif method == Riemann.middle:
              return torch.linspace(
                  1 / (2 * n), 1 - 1 / (2 * n), n
              ).tolist()
          elif method == Riemann.right:
              return torch.linspace(1 / n, 1, n).tolist()
          else:
              raise AssertionError(
                  "Provided Reimann approximation method is not valid."
              )
          # This is not a standard riemann method but in many cases it
          # leades to faster approaximation. Test cases for small number of steps
          # do not make sense but for larger number of steps the approximation is
          # better therefore leaving this option available
          # if method == 'riemann_include_endpoints':
          #     return [i / (n - 1) for i in range(n)]
  
      return step_sizes, alphas
  
file_path: captum/captum/attr/_utils/approximation_methods.py
imports: from enum import Enum
  from typing import Callable, List, Tuple
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: riemann_builders(method) and returns: step_sizes,  alphas, deltas, torch, torch, torch, torch