class_docstr: This class tests all autograd-related functionality.
docstr: Tests registration of new autograd function.
docstr_tok: ["Tests","registration","of","new","autograd","function","."]
code: def test_autograd_registation(self):
      """Tests registration of new autograd function."""
  
      # check that get_grad_fn() returns correct functions:
      for (
          func_name,
          reference_func,
      ) in gradients.FUNCTION_REGISTRY.items():
          grad_fn = gradients.get_grad_fn(func_name)
          self.assertEqual(grad_fn, reference_func)
          self.assertEqual(grad_fn.name, func_name)
  
      # check that non-existing functions return None:
      for invalid_func_name in ["bfobofb", "djhfhr"]:
          func = gradients.get_grad_fn(invalid_func_name)
          self.assertIsNone(func)
  
      # check that registering new classes works:
      for func_name in ["mock_func1", "mock_func2", "mock_func3"]:
          cls = type("%sName" % func_name, (AutogradFunction,), {})
          gradients.register_function(func_name)(cls)
          grad_fn = gradients.get_grad_fn(func_name)
          self.assertEqual(grad_fn, cls)
          self.assertEqual(grad_fn.name, func_name)
  
      # check that existing functions cannot be overwritten:
      for func_name in ["add", "sub", "view"]:
          cls = type("%sName" % func_name, (AutogradFunction,), {})
          with self.assertRaises(ValueError):
              gradients.register_function(func_name)(cls)
  
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 5 for calling the TestAutograd obj's underlying member method code with example usage: obj.test_autograd_registation() without return types