code: def batched_feed_forward_with_extras_to_actor_core(
      policy: FeedForwardPolicyWithExtra,
  ) -> ActorCore[
      SimpleActorCoreStateWithExtras, Mapping[str, jnp.ndarray]
  ]:
      """A convenience adaptor from FeedForwardPolicy to ActorCore."""
  
      def select_action(
          params: networks_lib.Params,
          observation: networks_lib.Observation,
          state: SimpleActorCoreStateWithExtras,
      ):
          rng = state.rng
          rng1, rng2 = jax.random.split(rng)
          observation = utils.add_batch_dim(observation)
          action, extras = utils.squeeze_batch_dim(
              policy(params, rng1, observation)
          )
          return action, SimpleActorCoreStateWithExtras(rng2, extras)
  
      def init(rng: PRNGKey) -> SimpleActorCoreStateWithExtras:
          return SimpleActorCoreStateWithExtras(rng, {})
  
      def get_extras(
          state: SimpleActorCoreStateWithExtras,
      ) -> Mapping[str, jnp.ndarray]:
          return state.extras
  
      return ActorCore(
          init=init, select_action=select_action, get_extras=get_extras
      )
  
file_path: acme/acme/agents/jax/actor_core.py
imports: import dataclasses
  from typing import Callable, Generic, Mapping, Tuple, TypeVar, Union
  from acme import types
  from acme.jax import networks
  from acme.jax import utils
  from acme.jax.types import PRNGKey
  import chex
  import jax
  import jax.numpy
label_desc: Use image node_id 3 for calling a global function with example usage: batched_feed_forward_with_extras_to_actor_core(policy) and returns: ActorCore, action,  SimpleActorCoreStateWithExtras, SimpleActorCoreStateWithExtras, state