class_docstr: To run: "python -m saliency.core.occlusion_test" from top-level saliency directory.
class_docstr_tok: ["To","run",":","``","python","-m","saliency.core.occlusion_test","''","from","top-level","saliency","directory","."]
docstr: Tests the Occlusion method using a simple network.
  
  Simple test case where the network multiplies all values by 3, and the input
  image has all zero values except at positions [1,1] and [3,3].
  
  The computed Occlusion mask should bias the center, but the quadrants with
  nonzero values should be greater than the other two (exact expected values
  stored in ref_mask).
docstr_tok: ["Tests","the","Occlusion","method","using","a","simple","network",".","Simple","test","case","where","the","network","multiplies","all","values","by","3",",","and","the","input","image","has","all","zero","values","except","at","positions","[","1,1","]","and","[","3,3","]",".","The","computed","Occlusion","mask","should","bias","the","center",",","but","the","quadrants","with","nonzero","values","should","be","greater","than","the","other","two","(","exact","expected","values","stored","in","ref_mask",")","."]
code: def testOcclusionGetMask(self):
      """Tests the Occlusion method using a simple network.
  
      Simple test case where the network multiplies all values by 3, and the input
      image has all zero values except at positions [1,1] and [3,3].
  
      The computed Occlusion mask should bias the center, but the quadrants with
      nonzero values should be greater than the other two (exact expected values
      stored in ref_mask).
      """
  
      def create_call_model_function():
          def call_model(
              x_value_batch, call_model_args=None, expected_keys=None
          ):
              # simulates output where all values are multiplied by 3.
              output = [np.sum(x_value_batch) * 3]
              return {occlusion.OUTPUT_LAYER_VALUES: output}
  
          return call_model
  
      call_model_function = create_call_model_function()
      # Generate test input and generate corresponding Occlusion mask
      img = np.zeros([INPUT_HEIGHT_WIDTH, INPUT_HEIGHT_WIDTH])
      img[1, 1] = 1
      img[3, 3] = 1
      img = img.reshape((INPUT_HEIGHT_WIDTH, INPUT_HEIGHT_WIDTH))
      ref_mask = np.array(
          [
              [3.0, 6.0, 6.0, 3.0, 0.0],
              [6.0, 15.0, 18.0, 12.0, 3.0],
              [6.0, 18.0, 24.0, 18.0, 6.0],
              [3.0, 12.0, 18.0, 15.0, 6.0],
              [0.0, 3.0, 6.0, 6.0, 3.0],
          ]
      )
  
      mask = self.occlusion_instance.GetMask(
          img,
          call_model_function=call_model_function,
          call_model_args=None,
          size=3,
          value=0,
      )
  
      # Compare generated mask to expected result
      self.assertTrue(
          np.allclose(mask, ref_mask, atol=0.01),
          "Generated mask did not match reference mask.",
      )
  
file_path: saliency/saliency/core/occlusion_test.py
imports: import unittest
  import unittest.mock
  from .base import OUTPUT_LAYER_VALUES
  from .base import SHAPE_ERROR_MESSAGE
  from .None import occlusion
  import numpy
label_desc: Use image node_id 2 for calling the OcclusionTest obj's underlying member method code with example usage: obj.testOcclusionGetMask() and returns: call_model, dict