code: def test_get_segments_from_frame_predictions_mr(self):
      class_probs = np.array(
          [
              [0, 1, 0, 0, 0, 0, 0, 0],
              [0, 0, 1, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 1, 1, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 1],
              [0, 0, 0, 0, 0, 0, 0, 0],
          ]
      )
      displacements = np.array(
          [
              [
                  [-5.00000000e-01, 1.00000000e00],
                  [5.00000000e-01, 0.00000000e00],
                  [1.50000000e00, -1.00000000e00],
                  [2.50000000e00, -2.00000000e00],
                  [3.50000000e00, -3.00000000e00],
                  [4.50000000e00, -4.00000000e00],
                  [5.50000000e00, -5.00000000e00],
                  [6.50000000e00, -6.00000000e00],
              ],
              [
                  [-1.50000000e00, 2.50000000e00],
                  [-5.00000000e-01, 1.50000000e00],
                  [5.00000000e-01, 5.00000000e-01],
                  [1.50000000e00, -5.00000000e-01],
                  [2.50000000e00, -1.50000000e00],
                  [3.50000000e00, -2.50000000e00],
                  [4.50000000e00, -3.50000000e00],
                  [5.50000000e00, -4.50000000e00],
              ],
              [
                  [-4.00000000e00, 5.00000000e00],
                  [-3.00000000e00, 4.00000000e00],
                  [-2.00000000e00, 3.00000000e00],
                  [-1.00000000e00, 2.00000000e00],
                  [0.00000000e00, 1.00000000e00],
                  [1.00000000e00, 0.00000000e00],
                  [2.00000000e00, -1.00000000e00],
                  [3.00000000e00, -2.00000000e00],
              ],
              [
                  [-6.50000000e00, 7.00000000e00],
                  [-5.50000000e00, 6.00000000e00],
                  [-4.50000000e00, 5.00000000e00],
                  [-3.50000000e00, 4.00000000e00],
                  [-2.50000000e00, 3.00000000e00],
                  [-1.50000000e00, 2.00000000e00],
                  [-5.00000000e-01, 1.00000000e00],
                  [5.00000000e-01, 0.00000000e00],
              ],
              [
                  [5.00000000e02, -5.00000000e02],
                  [5.01000000e02, -5.01000000e02],
                  [5.02000000e02, -5.02000000e02],
                  [5.03000000e02, -5.03000000e02],
                  [5.04000000e02, -5.04000000e02],
                  [5.05000000e02, -5.05000000e02],
                  [5.06000000e02, -5.06000000e02],
                  [5.07000000e02, -5.07000000e02],
              ],  # mask out
          ]
      )
  
      input_mask = np.array(
          [1, 1, 1, 1, 1, 1, 1, 1],
          dtype=np.int32,
      )
      caption_mask = np.array(
          [1, 1, 1, 1, 0],
          dtype=np.int32,
      )
      total_frames = np.array([15], dtype=np.int32)
      (
          actual_class_probs,
          actual_segments,
      ) = postprocessing_utils.get_segments_from_frame_predictions_mr(
          class_probs,
          displacements,
          input_mask=input_mask,
          caption_mask=caption_mask,
          total_frames=total_frames,
          stride=1,
          sampling_strategy="linspace",
          displacement_normalizer="none",
          secs_per_timestep=1.0,
          feature_pyramid_config=ml_collections.ConfigDict(
              {
                  "num_features_level0": 8,
                  "feature_pyramid_downsample_stride": 2,
                  "feature_pyramid_levels": [2],
              }
          ),
      )
      cls_probs = class_probs[caption_mask.astype(bool)]
      cls_probs = cls_probs[:, input_mask.astype(bool)]
      self.assertAllClose(actual_class_probs, cls_probs)
      expected_segments = np.array(
          [
              [
                  [1, 2],
                  [1, 2],
                  [1, 2],
                  [1, 2],
                  [1, 2],
                  [1, 2],
                  [1, 2],
                  [1, 2],
              ],
              [
                  [3, 5],
                  [3, 5],
                  [3, 5],
                  [3, 5],
                  [3, 5],
                  [3, 5],
                  [3, 5],
                  [3, 5],
              ],
              [
                  [8, 10],
                  [8, 10],
                  [8, 10],
                  [8, 10],
                  [8, 10],
                  [8, 10],
                  [8, 10],
                  [8, 10],
              ],
              [
                  [13, 14],
                  [13, 14],
                  [13, 14],
                  [13, 14],
                  [13, 14],
                  [13, 14],
                  [13, 14],
                  [13, 14],
              ],
          ]
      )
      self.assertAllClose(actual_segments, expected_segments)
  
file_path: scenic/scenic/projects/unloc/postprocessing_utils_test.py
imports: from absl.testing import parameterized
  import ml_collections
  import numpy
  from scenic.projects.unloc import metrics
  from scenic.projects.unloc import postprocessing_utils
  import tensorflow
label_desc: Use image node_id 5 for calling the PostprocessingUtilsTest obj's underlying member method code with example usage: obj.test_get_segments_from_frame_predictions_mr() without return types