code: def compute_changed_segments(
      name: str,
      src_segments: List[Segment],
      dst_segments: List[Segment],
      src_duration: float,
      dst_duration: float,
      speed_factor: float,
      **kwargs,
  ) -> Tuple[List[Segment], List[Segment]]:
      """
      This function performs the logic of computing the new matching segments based
      on the old ones, for the set of transforms that temporally change the video.
  
      Returns the lists of new src segments & dst segments, respectively.
      """
      new_src_segments, new_dst_segments = [], []
      td = get_transition_duration(kwargs)
      for src_segment, dst_segment in zip(src_segments, dst_segments):
          if name == "insert_in_background":
              # Note: When we implement insert_in_background, make sure to pass these kwargs
              offset = (
                  kwargs["offset_factor"]
                  * kwargs["background_video_duration"]
              )
              transition_before = int(kwargs["transition_before"])
              transition_after = int(kwargs["transition_after"])
              # The matching segments are just offset in the dst audio by the amount
              # of background video inserted before the src video.
              new_src_segments.append(
                  src_segment.delta(
                      transition_before * td / 2,
                      -transition_after * td / 2,
                  )
              )
              new_dst_segments.append(
                  Segment(
                      dst_segment.start
                      + offset
                      - transition_before * td / 2,
                      dst_segment.end
                      + offset
                      - transition_before * td
                      - transition_after * td / 2,
                  )
              )
          elif name == "insert_in_background_multiple":
              compute_insert_in_background_multiple_segments(
                  src_segment_starts=kwargs["src_segment_starts"],
                  src_segment_ends=kwargs["src_segment_ends"],
                  bkg_insertion_points=kwargs["bkg_insertion_points"],
                  src_ids=kwargs["src_ids"],
                  transition_duration=td,
                  new_src_segments=new_src_segments,
                  new_dst_segments=new_dst_segments,
              )
          elif name == "replace_with_background":
              clip_start = kwargs["starting_background_duration"]
              duration = kwargs["source_duration"]
              compute_time_crop_segments(
                  src_segment,
                  dst_segment,
                  speed_factor,
                  clip_start,
                  clip_start + duration,
                  new_src_segments,
                  new_dst_segments,
                  end_dst_offset=clip_start,
              )
          elif name == "change_video_speed":
              crt_factor = kwargs["factor"]
              global_factor = crt_factor * speed_factor
              new_src_segments.append(src_segment)
              new_dst_segments.append(
                  Segment(
                      dst_segment.start / global_factor,
                      dst_segment.end / global_factor,
                  )
              )
          elif name == "concat":
              src_index = kwargs["src_video_path_index"]
              num_videos = len(kwargs["video_paths"])
              transition_offset_start = td / 2 if src_index > 0 else 0.0
              transition_offset_end = (
                  td / 2 if src_index < num_videos - 1 else 0.0
              )
              new_src_segments.append(
                  src_segment.delta(
                      transition_offset_start, -transition_offset_end
                  )
              )
              offset = sum(
                  float(helpers.get_video_info(vp)["duration"]) - td
                  for vp in kwargs["video_paths"][
                      : kwargs["src_video_path_index"]
                  ]
              )
              new_dst_segments.append(
                  Segment(
                      dst_segment.start
                      + offset
                      + transition_offset_start,
                      dst_segment.end + offset - transition_offset_end,
                  )
              )
          elif name == "loop":
              # The existing segments are unchanged.
              new_src_segments.append(src_segment)
              new_dst_segments.append(dst_segment)
              # Each original src segments now additionally matches a segment in
              # each loop in the dst video.
              for l_idx in range(kwargs["num_loops"]):
                  new_src_segments.append(src_segment)
                  new_dst_segments.append(
                      Segment(
                          dst_segment.start
                          + (l_idx + 1) * src_duration,
                          dst_segment.end + (l_idx + 1) * src_duration,
                      )
                  )
          elif name == "time_crop":
              crop_start = kwargs["offset_factor"] * src_duration
              crop_end = (
                  crop_start + kwargs["duration_factor"] * src_duration
              )
              compute_time_crop_segments(
                  src_segment,
                  dst_segment,
                  speed_factor,
                  crop_start,
                  crop_end,
                  new_src_segments,
                  new_dst_segments,
              )
          elif name == "time_decimate":
              compute_time_decimate_segments(
                  src_segment,
                  dst_segment,
                  src_duration,
                  speed_factor,
                  td,
                  new_src_segments,
                  new_dst_segments,
                  **kwargs,
              )
          elif name == "trim":
              crop_start = kwargs["start"] or 0.0
              crop_end = kwargs["end"] or src_duration
              compute_time_crop_segments(
                  src_segment,
                  dst_segment,
                  speed_factor,
                  crop_start,
                  crop_end,
                  new_src_segments,
                  new_dst_segments,
              )
          elif name == "replace_with_color_frames":
              # This transform is like the inverse of time_crop/trim, because
              # offset & duration denote where the src content is being cropped
              # out, instead of which src content is being kept.
              offset = kwargs["offset_factor"] * src_duration
              duration = kwargs["duration_factor"] * src_duration
              compute_time_crop_segments(
                  src_segment,
                  dst_segment,
                  speed_factor,
                  0.0,
                  offset,
                  new_src_segments,
                  new_dst_segments,
              )
              compute_time_crop_segments(
                  src_segment,
                  dst_segment,
                  speed_factor,
                  offset + duration,
                  dst_duration,
                  new_src_segments,
                  new_dst_segments,
              )
      return new_src_segments, new_dst_segments
  
file_path: AugLy/augly/video/helpers/metadata.py
imports: from copy import deepcopy
  from typing import Any, Dict, List, Optional, Tuple
  from augly import utils
  from augly.video import helpers
  from augly.video.helpers import intensity
label_desc: Use image node_id 6 for calling a global function with example usage: compute_changed_segments(name, src_segments, dst_segments, src_duration, dst_duration, speed_factor) and returns: new_src_segments,  new_dst_segments