code: def masked_max(vector, mask, dim, keepdim=False, min_val=-1e7):
      """
      To calculate max along certain dimensions on masked values
  
      Parameters
      ----------
      vector : ``torch.Tensor``
          The vector to calculate max, assume unmasked parts are already zeros
      mask : ``torch.Tensor``
          The mask of the vector. It must be broadcastable with vector.
      dim : ``int``
          The dimension to calculate max
      keepdim : ``bool``
          Whether to keep dimension
      min_val : ``float``
          The minimal value for paddings
  
      Returns
      -------
      A ``torch.Tensor`` of including the maximum values.
      """
      one_minus_mask = (1.0 - mask).byte()
      replaced_vector = vector.masked_fill(one_minus_mask, min_val)
      max_value, _ = replaced_vector.max(dim=dim, keepdim=keepdim)
      return max_value
  
imports: from __future__ import division
  from __future__ import absolute_import
  from collections import defaultdict
  import logging
  import math
  import torch
  from allennlp.common.checks import ConfigurationError
label_desc: Use image node_id 9 for calling a global function with example usage: masked_max(vector, mask, dim, keepdim, min_val) and returns: max_value