code: def default_trajectory_length_constrain(
      trajectory_length_params: DefaultTrajectoryLengthParams,
      max_trajectory_length: float | fun_mc.FloatArray = 3.0,
  ) -> DefaultTrajectoryLengthParams:
      """Constrains the trajectory parameters.
  
      Args:
        trajectory_length_params: `DefaultTrajectoryLengthParams`.
        max_trajectory_length: Maximum mean trajectory length.
  
      Returns:
        trajectory_length_params: Constrained trajectory params.
      """
      max_trajectory_length = jnp.asarray(
          max_trajectory_length,
          trajectory_length_params.log_mean_trajectory_length.dtype,
      )
  
      return trajectory_length_params._replace(
          log_mean_trajectory_length=jnp.minimum(
              trajectory_length_params.log_mean_trajectory_length,
              jnp.log(max_trajectory_length),
          )
      )
  
imports: from collections.abc import Mapping
  from typing import Any, Callable, NamedTuple, Optional
  import immutabledict
  from fun_mc import backend
  from fun_mc import fun_mc_lib
label_desc: Use image node_id 6 for calling a global function with example usage: default_trajectory_length_constrain(trajectory_length_params, max_trajectory_length) and returns: trajectory_length_params