code: def _report_obs(
      *,
      results,
      computed_float_obs_B_T_dims,
      sampled_obs_B_T_dims,
      descr_prefix=None,
      descr_obs,
      symlog_obs,
  ):
      """Summarizes computed- vs sampled observations: MSE and (if applicable) images.
  
      Args:
          computed_float_obs_B_T_dims: Computed float observations
              (not clipped, not cast'd). Shape=(B, T, [dims ...]).
          sampled_obs_B_T_dims: Sampled observations (as-is from the environment, meaning
              this could be uint8, 0-255 clipped images). Shape=(B, T, [dims ...]).
          B: The batch size B (see shapes of `computed_float_obs_B_T_dims` and
              `sampled_obs_B_T_dims` above).
          T: The batch length T (see shapes of `computed_float_obs_B_T_dims` and
              `sampled_obs_B_T_dims` above).
          descr: A string used to describe the computed data to be used in the TB
              summaries.
      """
      # Videos: Create summary, comparing computed images with actual sampled ones.
      # 4=[B, T, w, h] grayscale image; 5=[B, T, w, h, C] RGB image.
      if len(sampled_obs_B_T_dims.shape) in [4, 5]:
          descr_prefix = (descr_prefix + "_") if descr_prefix else ""
  
          if symlog_obs:
              computed_float_obs_B_T_dims = inverse_symlog(
                  computed_float_obs_B_T_dims
              )
  
          # Restore image pixels from normalized (non-symlog'd) data.
          if not symlog_obs:
              computed_float_obs_B_T_dims = (
                  computed_float_obs_B_T_dims + 1.0
              ) * 128
              sampled_obs_B_T_dims = (sampled_obs_B_T_dims + 1.0) * 128
              sampled_obs_B_T_dims = np.clip(
                  sampled_obs_B_T_dims, 0.0, 255.0
              ).astype(np.uint8)
          computed_images = np.clip(
              computed_float_obs_B_T_dims, 0.0, 255.0
          ).astype(np.uint8)
          # Concat sampled and computed images along the height axis (3) such that
          # real images show below respective predicted ones.
          # (B, T, C, h, w)
          sampled_vs_computed_images = np.concatenate(
              [computed_images, sampled_obs_B_T_dims],
              axis=3,
          )
          # Add grayscale dim, if necessary.
          if len(sampled_obs_B_T_dims.shape) == 2 + 2:
              sampled_vs_computed_images = np.expand_dims(
                  sampled_vs_computed_images, -1
              )
  
          results.update(
              {
                  f"{descr_prefix}sampled_vs_{descr_obs}_videos": sampled_vs_computed_images
              }
          )
  
file_path: ray/rllib/algorithms/dreamerv3/utils/summaries.py
imports: import numpy
  from ray.rllib.algorithms.dreamerv3.utils.debugging import create_cartpole_dream_image, create_frozenlake_dream_image
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.tf_utils import inverse_symlog
label_desc: Use image node_id 7 for calling a global function with example usage: _report_obs() without return types