class_docstr: This class tests all autograd-related functionality.
docstr: Tests that detach() works as expected.
docstr_tok: ["Tests","that","detach","(",")","works","as","expected","."]
code: def test_detach(self):
      """Tests that detach() works as expected."""
  
      for func_name in ["detach", "detach_"]:
          # get test case:
          input_size = (12, 5)
          input1 = get_random_test_tensor(
              size=input_size, is_float=True
          )
          input2 = get_random_test_tensor(
              size=input_size, is_float=True
          )
          input1 = crypten.cryptensor(input1, requires_grad=True)
          input2 = crypten.cryptensor(input2, requires_grad=True)
  
          # perform forward computation with detach in the middle:
          intermediate = input1.add(1.0)
          intermediate = getattr(intermediate, func_name)()
          output = intermediate.add(input2).sum()
  
          # perform backward:
          output.backward()
          msg = "detach() function does not behave as expected"
          self.assertIsNone(output.grad, msg)
          self.assertIsNone(intermediate.grad, msg)
          self.assertIsNone(input1.grad, msg)
          self.assertIsNotNone(input2.grad, msg)
  
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 7 for calling the TestAutograd obj's underlying member method code with example usage: obj.test_detach() without return types