code: def apply_mask(y_p, sw, mask):
      """Applies any mask on predictions to sample weights."""
      if mask is not None:
          mask = math_ops.cast(mask, y_p.dtype)
          if sw is not None:
              mask, _, sw = losses_utils.squeeze_or_expand_dimensions(
                  mask, sample_weight=sw
              )
              sw *= mask
          else:
              sw = mask
      return sw
  
imports: import copy
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.keras import losses
  from tensorflow.python.keras import metrics
  from tensorflow.python.keras.utils import generic_utils
  from tensorflow.python.keras.utils import losses_utils
  from tensorflow.python.keras.utils import tf_utils
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 8 for calling a global function with example usage: apply_mask(y_p, sw, mask) and returns: sw