code: def make_actor_core(
      mppi_config: mppi.MPPIConfig,
      world_model: models.WorldModel,
      policy_prior: models.PolicyPrior,
      n_step_return: models.NStepReturn,
      environment_spec: specs.EnvironmentSpec,
      mean_std: Optional[running_statistics.NestedMeanStd] = None,
  ) -> ActorCore:
      """Creates an actor core wrapping the MBOP-configured MPPI planner.
  
      Args:
        mppi_config: Planner hyperparameters.
        world_model: A world model.
        policy_prior: A policy prior.
        n_step_return: An n-step return.
        environment_spec: Used to initialize the initial trajectory data structure.
        mean_std: Used to undo normalization if the networks trained normalized.
  
      Returns:
        A recurrent actor core.
      """
  
      if mean_std is not None:
          mean_std_observation = running_statistics.NestedMeanStd(
              mean=mean_std.mean.observation,
              std=mean_std.std.observation,
          )
          mean_std_action = running_statistics.NestedMeanStd(
              mean=mean_std.mean.action, std=mean_std.std.action
          )
          mean_std_reward = running_statistics.NestedMeanStd(
              mean=mean_std.mean.reward, std=mean_std.std.reward
          )
          mean_std_n_step_return = running_statistics.NestedMeanStd(
              mean=mean_std.mean.extras["n_step_return"],
              std=mean_std.std.extras["n_step_return"],
          )
  
          def denormalized_world_model(
              params: networks_lib.Params,
              observation_t: networks_lib.Observation,
              action_t: networks_lib.Action,
          ) -> Tuple[networks_lib.Observation, networks_lib.Value]:
              """Denormalizes the reward for proper weighting in the planner."""
              observation_tp1, normalized_reward_t = world_model(
                  params, observation_t, action_t
              )
              reward_t = running_statistics.denormalize(
                  normalized_reward_t, mean_std_reward
              )
              return observation_tp1, reward_t
  
          planner_world_model = denormalized_world_model
  
          def denormalized_n_step_return(
              params: networks_lib.Params,
              observation_t: networks_lib.Observation,
              action_t: networks_lib.Action,
          ) -> networks_lib.Value:
              """Denormalize the n-step return for proper weighting in the planner."""
              normalized_n_step_return_t = n_step_return(
                  params, observation_t, action_t
              )
              return running_statistics.denormalize(
                  normalized_n_step_return_t, mean_std_n_step_return
              )
  
          planner_n_step_return = denormalized_n_step_return
      else:
          planner_world_model = world_model
          planner_n_step_return = n_step_return
  
      def recurrent_policy(
          params_list: List[networks_lib.Params],
          random_key: networks_lib.PRNGKey,
          observation: networks_lib.Observation,
          previous_trajectory: Trajectory,
      ) -> Tuple[networks_lib.Action, Trajectory]:
          # Note that splitting the random key is handled by GenericActor.
          if mean_std is not None:
              observation = running_statistics.normalize(
                  observation, mean_std=mean_std_observation
              )
          trajectory = mppi.mppi_planner(
              config=mppi_config,
              world_model=planner_world_model,
              policy_prior=policy_prior,
              n_step_return=planner_n_step_return,
              world_model_params=params_list[0],
              policy_prior_params=params_list[1],
              n_step_return_params=params_list[2],
              random_key=random_key,
              observation=observation,
              previous_trajectory=previous_trajectory,
          )
          action = trajectory[0, ...]
          if mean_std is not None:
              action = running_statistics.denormalize(
                  action, mean_std=mean_std_action
              )
          return (action, trajectory)
  
      batched_policy = jax.vmap(
          recurrent_policy, in_axes=(None, None, 0, 0)
      )
      batched_policy = jax.jit(batched_policy)
  
      initial_trajectory = mppi.get_initial_trajectory(
          config=mppi_config, env_spec=environment_spec
      )
      initial_trajectory = jnp.expand_dims(initial_trajectory, axis=0)
  
      return actor_core_lib.batched_recurrent_to_actor_core(
          batched_policy, initial_trajectory
      )
  
file_path: acme/acme/agents/jax/mbop/acting.py
imports: from typing import List, Mapping, Optional, Tuple
  from acme import adders
  from acme import core
  from acme import specs
  from acme.agents.jax import actor_core
  from acme.agents.jax import actors
  from acme.agents.jax.mbop import models
  from acme.agents.jax.mbop import mppi
  from acme.agents.jax.mbop import networks
  from acme.jax import networks
  from acme.jax import running_statistics
  from acme.jax import variable_utils
  import jax
  from jax import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: make_actor_core(mppi_config, world_model, policy_prior, n_step_return, environment_spec, mean_std) and returns: actor_core_lib, action,  trajectory, observation_tp1,  reward_t, running_statistics