code: def calculate_priorities(
      priority_fns: base.PriorityFnMapping,
      trajectory_or_transition: Union[
          base.Trajectory, types.Transition
      ],
  ) -> Dict[str, float]:
      """Helper used to calculate the priority of a Trajectory or Transition.
  
      This helper converts the leaves of the Trajectory or Transition from
      `reverb.TrajectoryColumn` objects into numpy arrays. The converted Trajectory
      or Transition is then passed into each of the functions in `priority_fns`.
  
      Args:
        priority_fns: a mapping from table names to priority functions (i.e. a
          callable of type PriorityFn). The given function will be used to generate
          the priority (a float) for the given table.
        trajectory_or_transition: the trajectory or transition used to compute
          priorities.
  
      Returns:
        A dictionary mapping from table names to the priority (a float) for the
        given collection Trajectory or Transition.
      """
      if any(
          [
              priority_fn is not None
              for priority_fn in priority_fns.values()
          ]
      ):
          trajectory_or_transition = tree.map_structure(
              lambda col: col.numpy(), trajectory_or_transition
          )
  
      return {
          table: (
              priority_fn(trajectory_or_transition)
              if priority_fn
              else 1.0
          )
          for table, priority_fn in priority_fns.items()
      }
  
file_path: acme/acme/adders/reverb/utils.py
imports: from typing import Dict, Union
  from acme import types
  from acme.adders.reverb import base
  import jax
  import jax.numpy
  import numpy
  import tree
label_desc: Use image node_id 3 for calling a global function with example usage: calculate_priorities(priority_fns, trajectory_or_transition) and returns: unknown