class_docstr: Wraps the base_plugin.TBContext to stores additional data shared across
  API handlers for the HParams plugin backend.
  
  Before adding fields to this class, carefully consider whether the
  field truly needs to be accessible to all API handlers or if it
  can be passed separately to the handler constructor. We want to
  avoid this class becoming a magic container of variables that have
  no better place. See http://wiki.c2.com/?MagicContainer
class_docstr_tok: ["Wraps","the","base_plugin.TBContext","to","stores","additional","data","shared","across","API","handlers","for","the","HParams","plugin","backend",".","Before","adding","fields","to","this","class",",","carefully","consider","whether","the","field","truly","needs","to","be","accessible","to","all","API","handlers","or","if","it","can","be","passed","separately","to","the","handler","constructor",".","We","want","to","avoid","this","class","becoming","a","magic","container","of","variables","that","have","no","better","place",".","See","http",":","\/\/wiki.c2.com\/","?","MagicContainer"]
docstr: Returns an experiment protobuffer based on data provider hparams.
  
  Args:
    experiment_id: String, from `plugin_util.experiment_id`.
    include_metrics: Whether to determine metrics_infos and include them
      in the result.
    data_provider_hparams: The output from an hparams_from_data_provider()
      call, corresponding to DataProvider.list_hyperparameters().
      A provider.ListHyperparametersResult.
  
  Returns:
    The experiment proto. If there are no hyperparameters in the input,
    returns None.
docstr_tok: ["Returns","an","experiment","protobuffer","based","on","data","provider","hparams",".","Args",":","experiment_id",":","String",",","from","`","plugin_util.experiment_id","`",".","include_metrics",":","Whether","to","determine","metrics_infos","and","include","them","in","the","result",".","data_provider_hparams",":","The","output","from","an","hparams_from_data_provider","(",")","call",",","corresponding","to","DataProvider.list_hyperparameters","(",")",".","A","provider.ListHyperparametersResult",".","Returns",":","The","experiment","proto",".","If","there","are","no","hyperparameters","in","the","input",",","returns","None","."]
code: def _experiment_from_data_provider_hparams(
      self,
      ctx,
      experiment_id,
      include_metrics,
      data_provider_hparams,
  ):
      """Returns an experiment protobuffer based on data provider hparams.
  
      Args:
        experiment_id: String, from `plugin_util.experiment_id`.
        include_metrics: Whether to determine metrics_infos and include them
          in the result.
        data_provider_hparams: The output from an hparams_from_data_provider()
          call, corresponding to DataProvider.list_hyperparameters().
          A provider.ListHyperparametersResult.
  
      Returns:
        The experiment proto. If there are no hyperparameters in the input,
        returns None.
      """
      if isinstance(data_provider_hparams, list):
          # TODO: Support old return value of Collection[provider.Hyperparameters]
          # until all internal implementations of DataProvider can be
          # migrated to use new return value of provider.ListHyperparametersResult.
          hyperparameters = data_provider_hparams
          session_groups = []
      else:
          # Is instance of provider.ListHyperparametersResult
          hyperparameters = data_provider_hparams.hyperparameters
          session_groups = data_provider_hparams.session_groups
  
      hparam_infos = [
          self._convert_data_provider_hparam(dp_hparam)
          for dp_hparam in hyperparameters
      ]
      metric_infos = (
          self.compute_metric_infos_from_data_provider_session_groups(
              ctx, experiment_id, session_groups
          )
          if include_metrics
          else []
      )
      return api_pb2.Experiment(
          hparam_infos=hparam_infos, metric_infos=metric_infos
      )
  
imports: import collections
  import os
  from tensorboard.data import provider
  from tensorboard.plugins.hparams import api_pb2
  from tensorboard.plugins.hparams import json_format_compat
  from tensorboard.plugins.hparams import metadata
  from google.protobuf import json_format
  from tensorboard.plugins.scalar import metadata
label_desc: Use image node_id 14 for calling the Context obj's underlying member method code with example usage: obj._experiment_from_data_provider_hparams(ctx, experiment_id, include_metrics, data_provider_hparams) and returns: api_pb2