code: def mean_outshape(module_masks, mask, shape):
      """
      Similar to view operation, currently mask inference only supports
      the mean operation on the 3rd and 4th dimensions.
      """
      assert shape["in_shape"][0] == shape["out_shape"][0]
      assert shape["out_shape"][1] == shape["in_shape"][1]
      assert len(shape["in_shape"]) == 4
      assert len(shape["out_shape"]) == 2
  
      assert isinstance(mask, CoarseMask)
      assert mask.mask_index[1] is not None
      assert mask.mask_index[0] is None
      module_masks.set_output_mask(mask)
  
      input_cmask = CoarseMask(num_dim=4)
      input_cmask.add_index_mask(dim=1, index=mask.mask_index[1])
      module_masks.set_input_mask(input_cmask)
      return input_cmask
  
imports: import logging
  import torch
label_desc: Use image node_id 14 for calling a global function with example usage: mean_outshape(module_masks, mask, shape) and returns: input_cmask