code: def _unpad_and_resize(masks, padding_mask, orig_size):
      """Removes padding and resizes masks."""
      # Resize masks to the padding_mask size in case they have a lower resolution:
      masks = image_utils.resize_pil(
          masks,
          out_h=padding_mask.shape[0],
          out_w=padding_mask.shape[1],
          num_batch_dims=1,
          method="linear",
      )
      # Remove padding:
      row_masks = np.any(padding_mask, axis=-1)
      col_masks = np.any(padding_mask, axis=-2)
      masks = masks[:, row_masks, :]
      masks = masks[:, :, col_masks]
      # Resize to original size:
      return image_utils.resize_pil(
          masks,
          out_h=orig_size[0],
          out_w=orig_size[1],
          num_batch_dims=1,
          method="linear",
      )
  
imports: import copy
  import json
  import os
  from typing import Any, Dict, Optional, Set
  from absl import logging
  from flax import core
  from flax import optim
  from flax import traverse_util
  import jax
  from jax.example_libraries import optimizers
  import jax.numpy
  import numpy
  import PIL
  import PIL.ImageDraw
  import PIL.ImageFont
  from scenic.common_lib import image_utils
  from scenic.dataset_lib.coco_dataset import coco_eval
  from scenic.model_lib.base_models import box_utils
  from scenic.train_lib_deprecated import optimizers
  from scenic.train_lib_deprecated import train_utils
  import scipy.special
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: _unpad_and_resize(masks, padding_mask, orig_size) and returns: image_utils