code: def train_model_and_embed_images(
      config_path: str = None, **kwargs
  ) -> Tuple[np.ndarray, List[int], List[str]]:
      """Train a self-supervised model and use it to embed images.
  
      First trains a modle using the _train_cli(),
      then embeds with the _embed_cli().
      All arguments passed to the CLI functions
      can also be passed to this function (see below for an example).
  
      Args:
          config_path:
              Path to config.yaml. If None, the default configs will be used.
          **kwargs:
              Overwrite default configs py passing keyword arguments.
  
      Returns:
          Embeddings, labels, and filenames of the images.
          Embeddings are of shape (n_samples, embedding_size)
          len(labels) = len(filenames) = n_samples
  
      Examples:
          >>> import lightly
          >>>
          >>> # train a model and embed images with default configs
          >>> embeddings, _, _ = lightly.train_model_and_embed_images(
          >>>     input_dir='path/to/data')
          >>>
          >>> # train a model and embed images with separate config file
          >>> my_config_path = 'my/config/file.yaml'
          >>> embeddings, _, _ = lightly.train_model_and_embed_images(
          >>>     input_dir='path/to/data', config_path=my_config_path)
          >>>
          >>> # train a model and embed images with default settings + overwrites
          >>> my_trainer = {max_epochs: 10}
          >>> embeddings, _, _ = lightly.train_model_and_embed_images(
          >>>     input_dir='path/to/data', trainer=my_trainer)
  
      """
      config_path = _get_config_path(config_path)
      config_args = _load_config_file(config_path)
      config_args = _add_kwargs(config_args, kwargs)
  
      checkpoint = _train_cli(config_args, is_cli_call=False)
      config_args["checkpoint"] = checkpoint
      embeddings, labels, filenames = _embed_cli(
          config_args, is_cli_call=False
      )
      return embeddings, labels, filenames
  
file_path: lightly/lightly/core.py
imports: import os
  from typing import List, Tuple
  import numpy
  import yaml
  import lightly.cli
  from lightly.cli.embed_cli import _embed_cli
  from lightly.cli.lightly_cli import _lightly_cli
  from lightly.cli.train_cli import _train_cli
label_desc: Use image node_id 4 for calling a global function with example usage: train_model_and_embed_images(config_path) and returns: embeddings,  labels,  filenames