code: def adjust_segmentation_idxs(
      segmentation: ArrayLike,
      old_assets_list: Sequence[core.Asset],
      new_assets_list: Sequence[core.Asset],
      ignored_label: int = 0,
  ):
      """Replaces segmentation ids with either asset.segmentation_id or the index in new_assets_list.
  
      Note that this starts with index=1 for the first asset in new_assets_list, to leave id=0 for
      background assets.
      """
      new_segmentation = np.zeros_like(segmentation)
      for i, asset in enumerate(old_assets_list, start=1):
          if (
              isinstance(asset, core.PhysicalObject)
              and asset.segmentation_id is not None
          ):
              new_segmentation[
                  segmentation == i
              ] = asset.segmentation_id
          elif asset in new_assets_list:
              new_segmentation[segmentation == i] = (
                  new_assets_list.index(asset) + 1
              )
          else:
              new_segmentation[segmentation == i] = ignored_label
      return new_segmentation
  
imports: import numpy
  from typing import Sequence
  from kubric import core
  from kubric.kubric_typing import ArrayLike
label_desc: Use image node_id 2 for calling a global function with example usage: adjust_segmentation_idxs(segmentation, old_assets_list, new_assets_list, ignored_label) and returns: new_segmentation