class_docstr: This is a contextual dataset that is constructed from either a single
  dateset containing overall outcome or a list of datasets that each corresponds
  to a context breakdown.
docstr: Construct a `ContextualDataset`.
  
  Args:
      datasets: A list of the datasets of individual tasks. Each dataset
          is expected to contain data for only one outcome.
      parameter_decomposition: Dict from context name to list of indices
          of X corresponding to that context.
      context_buckets: List of the context names in the order of dataset
          in datasets corresponding to each context outcome.
      metric_decomposition: Context breakdown metrics. Keys are context names.
          Values are the lists of metric names belonging to the context:
          {'context1': ['m1_c1'], 'context2': ['m1_c2'],}.
code: def __init__(
      self,
      datasets: List[SupervisedDataset],
      parameter_decomposition: Dict[str, List[str]],
      context_buckets: List[str],
      metric_decomposition: Optional[Dict[str, List[str]]] = None,
  ):
      """Construct a `ContextualDataset`.
  
      Args:
          datasets: A list of the datasets of individual tasks. Each dataset
              is expected to contain data for only one outcome.
          parameter_decomposition: Dict from context name to list of indices
              of X corresponding to that context.
          context_buckets: List of the context names in the order of dataset
              in datasets corresponding to each context outcome.
          metric_decomposition: Context breakdown metrics. Keys are context names.
              Values are the lists of metric names belonging to the context:
              {'context1': ['m1_c1'], 'context2': ['m1_c2'],}.
      """
      self.datasets: Dict[str, SupervisedDataset] = {
          ds.outcome_names[0]: ds for ds in datasets
      }
      self.feature_names = datasets[0].feature_names
      self.outcome_names = list(self.datasets.keys())
      self.parameter_decomposition = parameter_decomposition
      self.context_buckets = context_buckets
      self.metric_decomposition = metric_decomposition
      self._validate_datasets(
          datasets=datasets, metric_decomposition=metric_decomposition
      )
      # order the dataset based on context bucket
      self.outcome_names = self._sort_outcome_names()
  
imports: from __future__ import annotations
  import collections
  import warnings
  from typing import Any, Dict, List, Optional, Union
  import torch
  from botorch.exceptions.errors import InputDataError, UnsupportedError
  from botorch.utils.containers import BotorchContainer, SliceContainer
  from torch import long, ones, Tensor
label_desc: Use image node_id 1 to create a new ContextualDataset object from inherited base classes: SupervisedDataset with example: obj = ContextualDataset(datasets, parameter_decomposition, context_buckets, metric_decomposition)