code: def test_convert_to_canonical_format(self):
      # Case: input is a list of strs
      self.assertDictEqual(
          convert_to_canonical_format(["foo", "bar"]).asdict(),
          SpecDict({"foo": None, "bar": None}).asdict(),
      )
  
      # Case: input is a list of strs and nested strs
      self.assertDictEqual(
          convert_to_canonical_format(["foo", ("bar", "jar")]).asdict(),
          SpecDict({"foo": None, "bar": {"jar": None}}).asdict(),
      )
  
      # Case: input is a Nested Mapping
      returned = convert_to_canonical_format(
          {
              "foo": {"bar": TensorSpec("b", framework="torch")},
              "jar": {"tar": int, "car": None},
          }
      )
      self.assertIsInstance(returned, SpecDict)
      self.assertDictEqual(
          returned.asdict(),
          SpecDict(
              {
                  "foo": {"bar": TensorSpec("b", framework="torch")},
                  "jar": {"tar": TypeSpec(int), "car": None},
              }
          ).asdict(),
      )
  
      # Case: input is a SpecDict already
      returned = convert_to_canonical_format(
          SpecDict(
              {
                  "foo": {"bar": TensorSpec("b", framework="torch")},
                  "jar": {"tar": int},
              }
          )
      )
      self.assertIsInstance(returned, SpecDict)
      self.assertDictEqual(
          returned.asdict(),
          SpecDict(
              {
                  "foo": {"bar": TensorSpec("b", framework="torch")},
                  "jar": {"tar": TypeSpec(int)},
              }
          ).asdict(),
      )
  
imports: import abc
  import time
  import unittest
  from typing import Dict, Any, Type
  import numpy
  import torch
  from ray.rllib.core.models.specs.checker import SpecCheckingError
  from ray.rllib.core.models.specs.checker import convert_to_canonical_format, check_input_specs, check_output_specs
  from ray.rllib.core.models.specs.specs_base import TensorSpec, TypeSpec
  from ray.rllib.core.models.specs.specs_dict import SpecDict
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.nested_dict import NestedDict
label_desc: Use image node_id 9 for calling the TestCheckSpecs obj's underlying member method code with example usage: obj.test_convert_to_canonical_format() without return types