code: def get_mask_valid_ratio(mask: jnp.ndarray) -> jnp.ndarray:
      """Get non-padded:padded ratio for width/height for each mask."""
      _, h, w = mask.shape
      valid_h = jnp.sum(mask[:, :, 0], 1)
      valid_w = jnp.sum(mask[:, 0, :], 1)
      valid_ratio_h = valid_h / h
      valid_ratio_w = valid_w / w
      valid_ratio = jnp.stack([valid_ratio_w, valid_ratio_h], -1)
      return valid_ratio
  
imports: import functools
  from typing import Sequence, Tuple
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.baselines.deformable_detr.attention import MultiScaleDeformableAttention
  from scenic.projects.baselines.detr.model import MultiHeadDotProductAttention
label_desc: Use image node_id 3 for calling a global function with example usage: get_mask_valid_ratio(mask) and returns: valid_ratio