code: def dict(keytype, valuetype):
      class dict:
          T = [keytype, valuetype]
  
          def __init__(self):
              self.val = {}
  
          @classmethod
          def __type_info__(cls):
              return Type(
                  "dict",
                  [get_type_info(keytype), get_type_info(valuetype)],
                  cls,
              )
  
          @annotate(T[1], key=T[0])
          def __getitem__(self, key):
              assert isinstance(key, self.T[0])
              return self.val[key]
  
          @annotate(void, key=T[0], newval=T[1])
          def __setitem__(self, key, newval):
              assert isinstance(key, self.T[0])
              assert isinstance(newval, self.T[1])
              self.val[key] = newval
  
          @annotate(type_int.int)
          def __len__(self):
              return type_int.int(len(self.val))
  
          @annotate(type_bool.bool, key=T[0])
          def __contains__(self, key):
              return key in self.val[key]
  
      dict.__template_name__ = (
          "dict[" + keytype.__name__ + "," + valuetype.__name__ + "]"
      )
      return dict
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/mil/types/type_dict.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from .annotate import annotate
  from .type_spec import Type
  from .None import type_bool
  from .None import type_int
  from .type_void import void
  from .get_type_info import get_type_info
label_desc: Use image node_id 2 for calling a global function with example usage: dict(keytype, valuetype) and returns: dict, Type, self, type_int, unknown