docstr: Test that del can be called on an instance of a class that
  overrides __delitem__.
docstr_tok: ["Test","that","del","can","be","called","on","an","instance","of","a","class","that","overrides","__delitem__","."]
code: def test_custom_delete(self):
      """
      Test that del can be called on an instance of a class that
      overrides __delitem__.
      """
  
      class Example:
          def __init__(self):
              self._data: Dict[str, torch.Tensor] = {
                  "1": torch.tensor(1.0)
              }
  
          def check(self, key: str) -> bool:
              return key in self._data
  
          def __delitem__(self, key: str):
              del self._data[key]
  
      def fn() -> bool:
          example = Example()
          del example["1"]
          return example.check("1")
  
      self.checkScript(fn, ())
  
      # Test the case in which the class does not have __delitem__ defined.
      class NoDelItem:
          def __init__(self):
              self._data: Dict[str, torch.Tensor] = {
                  "1": torch.tensor(1.0)
              }
  
          def check(self, key: str) -> bool:
              return key in self._data
  
      def fn() -> bool:
          example = NoDelItem()
          key = "1"
          del example[key]
          return example.check(key)
  
      with self.assertRaisesRegexWithHighlight(
          RuntimeError,
          r"Class does not define __delitem__",
          "example[key]",
      ):
          self.checkScript(fn, ())
  
imports: import io
  import os
  import sys
  import unittest
  import torch
  import torch.nn
  from torch.testing import FileCheck
  from typing import Any
  from torch.testing._internal.jit_utils import JitTestCase, make_global
  import torch.testing._internal.jit_utils
  from torch.testing._internal.common_utils import IS_SANDCASTLE, skipIfTorchDynamo
  from typing import List, Tuple, Iterable, Optional, Dict
label_desc: Use image node_id 39 for calling the TestClassType obj's underlying member method code with example usage: obj.test_custom_delete() and returns: example, example, unknown, unknown