def _update_requirements(config: dict) -> dict:
    """
    Generates requirements for DeepPavlov model and adds them as ``metadata.requirements`` field to the returned dict.

    Searches for the ``class_name`` keys in the passed config at all nesting levels. For each found component,
    function looks for dependencies in the requirements registry. Found dependencies are added to the returned copy of
    the config as ``metadata.requirements``. If the config already has ``metadata.requirements``, the existing one
    is complemented by the found requirements.

    Args:
        config: DeepPavlov model config
    Returns:
        config copy with updated ``metadata.requirements`` field according to the config components.
    """
    components = get_all_elems_from_json(config, 'class_name')
    components = {inverted_registry.get(component, component) for component in components}
    requirements_registry_path = Path(__file__).parents[1] / 'common' / 'requirements_registry.json'
    requirements_registry = read_json(requirements_registry_path)
    requirements = []
    for component in components:
        requirements.extend(requirements_registry.get(component, []))
    requirements.extend(config.get('metadata', {}).get('requirements', []))
    response = deepcopy(config)
    response['metadata'] = response.get('metadata', {})
    response['metadata']['requirements'] = list(set(requirements))
    return response

    Generates requirements for DeepPavlov model and adds them as ``metadata.requirements`` field to the returned dict.

    Searches for the ``class_name`` keys in the passed config at all nesting levels. For each found component,
    function looks for dependencies in the requirements registry. Found dependencies are added to the returned copy of
    the config as ``metadata.requirements``. If the config already has ``metadata.requirements``, the existing one
    is complemented by the found requirements.

    Args:
        config: DeepPavlov model config
    Returns:
        config copy with updated ``metadata.requirements`` field according to the config components.
    
deeppavlov/core/commands/utils.py