code: def get_dropout_mask(dropout_probability, tensor_for_masking):
      """
      Computes and returns an element-wise dropout mask for a given tensor, where
      each element in the mask is dropped out with probability dropout_probability.
      Note that the mask is NOT applied to the tensor - the tensor is passed to retain
      the correct CUDA tensor type for the mask.
  
      Parameters
      ----------
      dropout_probability : float, required.
          Probability of dropping a dimension of the input.
      tensor_for_masking : torch.Tensor, required.
  
  
      Returns
      -------
      A torch.FloatTensor consisting of the binary mask scaled by 1/ (1 - dropout_probability).
      This scaling ensures expected values and variances of the output of applying this mask
       and the original tensor are the same.
      """
      binary_mask = tensor_for_masking.new_tensor(
          torch.rand(tensor_for_masking.size()) > dropout_probability
      )
      # Scale mask by 1/keep_prob to preserve output statistics.
      dropout_mask = binary_mask.float().div(1.0 - dropout_probability)
      return dropout_mask
  
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 6 for calling a global function with example usage: get_dropout_mask(dropout_probability, tensor_for_masking) and returns: dropout_mask