code: def get_valid_ratio(self, mask):
      _, H, W = mask.shape
      valid_H = paddle.sum(~mask[:, :, 0], 1)
      valid_W = paddle.sum(~mask[:, 0, :], 1)
      valid_ratio_h = valid_H.astype("float32") / H
      valid_ratio_w = valid_W.astype("float32") / W
      valid_ratio = paddle.stack([valid_ratio_w, valid_ratio_h], -1)
      return valid_ratio
  
imports: import copy
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.cvlibs import param_init
  from paddlepanseg.models.param_init import c2_xavier_fill, THLinearInitMixin
  from .common import Conv2D, PositionEmbeddingSine
  from ._ms_deform_attn import MSDeformAttn
label_desc: Use image node_id 3 for calling the MSDeformAttnTransformerEncoderOnly obj's underlying member method code with example usage: obj.get_valid_ratio(mask) and returns: valid_ratio