code: def test_cast_overloads(self):
      @torch.jit.script
      class Foo:
          def __init__(self, val: float) -> None:
              self.val = val
  
          def __int__(self):
              return int(self.val)
  
          def __float__(self):
              return self.val
  
          def __bool__(self):
              return bool(self.val)
  
          def __str__(self):
              return str(self.val)
  
      make_global(Foo)  # see [local resolution in python]
  
      def test(foo: Foo) -> Tuple[int, float, bool]:
          if foo:
              pass
          return int(foo), float(foo), bool(foo)
  
      fn = torch.jit.script(test)
      self.assertEqual(fn(Foo(0.5)), test(0.5))
      self.assertEqual(fn(Foo(0.0)), test(0.0))
      # str has slightly different formatting
      self.assertTrue("0.5" in (str(Foo(0.5))))
      self.assertTrue("0." in (str(Foo(0.0))))
  
      @torch.jit.script
      class BadBool:
          def __init__(self):
              pass
  
          def __bool__(self):
              return (1, 2)
  
      with self.assertRaisesRegexWithHighlight(
          RuntimeError, "expected a bool expression for condition", ""
      ):
  
          @torch.jit.script
          def test():
              if BadBool():
                  print(1)
                  pass
  
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 25 for calling the TestClassType obj's underlying member method code with example usage: obj.test_cast_overloads() and returns: int,  float,  bool, int, self, bool, str, int,  int