def METHOD_NAME(yaml_data: Dict[str, Any], code_model: CodeModel) -> BaseType:
    yaml_id = id(yaml_data)
    try:
        return code_model.lookup_type(yaml_id)
    except KeyError:
        # Not created yet, let's create it and add it to the index
        pass
    if yaml_data["type"] == "model":
        # need to special case model to avoid recursion
        if yaml_data["base"] == "json" or not code_model.options["models_mode"]:
            model_type = JSONModelType
        elif yaml_data["base"] == "dpg":
            model_type = DPGModelType  # type: ignore
        else:
            model_type = MsrestModelType  # type: ignore
        response = model_type(yaml_data, code_model)
        code_model.types_map[yaml_id] = response
        response.fill_instance_from_yaml(yaml_data, code_model)
    else:
        object_type = yaml_data.get("type")
        if object_type not in TYPE_TO_OBJECT:
            _LOGGER.warning(
                'Unrecognized definition type "%s" is found, falling back it as "string"! ',
                yaml_data["type"],
            )
            object_type = "string"
        response = TYPE_TO_OBJECT[object_type].from_yaml(yaml_data, code_model)  # type: ignore
    code_model.types_map[yaml_id] = response
    return response