class_docstr: This class tests all autograd-related functionality.
docstr: Tests whether marking of non-differentiability works correctly.
docstr_tok: ["Tests","whether","marking","of","non-differentiability","works","correctly","."]
code: def test_non_differentiable_marking(self):
      """Tests whether marking of non-differentiability works correctly."""
  
      # generate random inputs:
      inputs = [get_random_test_tensor(is_float=True) for _ in range(5)]
      inputs = [crypten.cryptensor(input) for input in inputs]
      ctx = AutogradContext()
  
      # repeat test multiple times:
      for _ in range(10):
          # mark non-differentiable inputs as such:
          differentiable = [
              random.random() > 0.5 for _ in range(len(inputs))
          ]
          for idx, diff in enumerate(differentiable):
              if not diff:
                  ctx.mark_non_differentiable(inputs[idx])
  
          # check that inputs were correctly marked:
          for idx, input in enumerate(inputs):
              self.assertEqual(
                  ctx.is_differentiable(input),
                  differentiable[idx],
                  "marking of differentiability failed",
              )
          ctx.reset()
  
      # test behavior of autograd in CrypTensor:
      input = inputs[0]
      input.requires_grad = True
      reference = [True, True, False]
      for func_name in ["min", "max"]:
          outputs = [None] * 3
          outputs[0] = getattr(input, func_name)()
          outputs[1], outputs[2] = getattr(input, func_name)(0)
          for idx, output in enumerate(outputs):
              self.assertEqual(
                  output.requires_grad,
                  reference[idx],
                  "value of requires_grad is incorrect",
              )
  
      # behavior of max_pool2d in which indices are returned:
      input = get_random_test_tensor(size=(1, 3, 8, 8), is_float=True)
      input = crypten.cryptensor(input, requires_grad=True)
      reference = [True, True, False]
      outputs = [None] * 3
      outputs[0] = input.max_pool2d(2, return_indices=False)
      outputs[1], outputs[2] = input.max_pool2d(2, return_indices=True)
      for idx, output in enumerate(outputs):
          self.assertEqual(
              output.requires_grad,
              reference[idx],
              "value of requires_grad is incorrect",
          )
  
imports: import logging
  import random
  import unittest
  import crypten
  import crypten.gradients
  import torch
  from crypten.common.tensor_types import is_float_tensor
  from crypten.config import cfg
  from crypten.gradients import AutogradContext, AutogradFunction
  from test.multiprocess_test_case import get_random_test_tensor, MultiProcessTestCase
label_desc: Use image node_id 3 for calling the TestAutograd obj's underlying member method code with example usage: obj.test_non_differentiable_marking() without return types