code: def test_merge_cfg_from_cfg(self):
      # Test: merge from deepcopy
      s = "dummy0"
      cfg2 = copy.deepcopy(cfg)
      cfg2.MODEL.TYPE = s
      core_config.merge_cfg_from_cfg(cfg2)
      assert cfg.MODEL.TYPE == s
  
      # Test: merge from yaml
      s = "dummy1"
      cfg2 = core_config.load_cfg(yaml.dump(cfg))
      cfg2.MODEL.TYPE = s
      core_config.merge_cfg_from_cfg(cfg2)
      assert cfg.MODEL.TYPE == s
  
      # Test: merge with a valid key
      s = "dummy2"
      cfg2 = AttrDict()
      cfg2.MODEL = AttrDict()
      cfg2.MODEL.TYPE = s
      core_config.merge_cfg_from_cfg(cfg2)
      assert cfg.MODEL.TYPE == s
  
      # Test: merge with an invalid key
      s = "dummy3"
      cfg2 = AttrDict()
      cfg2.FOO = AttrDict()
      cfg2.FOO.BAR = s
      with self.assertRaises(KeyError):
          core_config.merge_cfg_from_cfg(cfg2)
  
      # Test: merge with converted type
      cfg2 = AttrDict()
      cfg2.TRAIN = AttrDict()
      cfg2.TRAIN.SCALES = [1]
      core_config.merge_cfg_from_cfg(cfg2)
      assert type(cfg.TRAIN.SCALES) is tuple
      assert cfg.TRAIN.SCALES[0] == 1
  
      # Test: merge with invalid type
      cfg2 = AttrDict()
      cfg2.TRAIN = AttrDict()
      cfg2.TRAIN.SCALES = 1
      with self.assertRaises(ValueError):
          core_config.merge_cfg_from_cfg(cfg2)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import copy
  import tempfile
  import unittest
  import yaml
  from detectron.core.config import cfg
  from detectron.utils.collections import AttrDict
  import detectron.core.config
  import detectron.utils.logging
label_desc: Use image node_id 2 for calling the TestCfg obj's underlying member method code with example usage: obj.test_merge_cfg_from_cfg() without return types