(self)
return tuple(
        (class_id, num_support, num_query)
        for class_id, num_support in zip(class_ids, num_support_per_class))
Returns the composition of an episode.

    Returns:
      A sequence of `(class_id, num_support, num_query)` tuples, where
        relative `class_id` is an integer in [0, self.num_classes).
Returns the composition of an episode.
Returns the composition of an episode .
def sample_episode_description(self):
    """Returns the composition of an episode.

    Returns:
      A sequence of `(class_id, num_support, num_query)` tuples, where
        relative `class_id` is an integer in [0, self.num_classes).
    """
    class_ids = self.sample_class_ids()
    images_per_class = np.array([
        self.dataset_spec.get_total_images_per_class(
            self.class_set[cid], pool=self.pool) for cid in class_ids
    ])

    if self.num_query is not None:
      num_query = self.num_query
    else:
      num_query = compute_num_query(
          images_per_class,
          max_num_query=self.max_num_query,
          num_support=self.num_support)

    if self.num_support is not None:
      if isinstance(self.num_support, int):
        if any(self.num_support + num_query > images_per_class):
          raise ValueError('Some classes do not have enough examples.')
        num_support = self.num_support
      else:
        start, end = self.num_support
        if any(end + num_query > images_per_class):
          raise ValueError('The range provided for uniform sampling of the '
                           'number of support examples per class is not valid: '
                           'some classes do not have enough examples.')
        num_support = self._rng.randint(low=start, high=end + 1)
      num_support_per_class = [num_support for _ in class_ids]
    else:
      num_remaining_per_class = images_per_class - num_query
      support_set_size = sample_support_set_size(
          num_remaining_per_class,
          self.max_support_size_contrib_per_class,
          max_support_set_size=self.max_support_set_size,
          rng=self._rng)
      num_support_per_class = sample_num_support_per_class(
          images_per_class,
          num_remaining_per_class,
          support_set_size,
          min_log_weight=self.min_log_weight,
          max_log_weight=self.max_log_weight,
          rng=self._rng)

    return tuple(
        (class_id, num_support, num_query)
        for class_id, num_support in zip(class_ids, num_support_per_class))
def sample_episode_description ( self ) : class_ids = self . sample_class_ids ( ) images_per_class = np . array ( [ self . dataset_spec . get_total_images_per_class ( self . class_set [ cid ] , pool = self . pool ) for cid in class_ids ] ) if self . num_query is not None : num_query = self . num_query else : num_query = compute_num_query ( images_per_class , max_num_query = self . max_num_query , num_support = self . num_support ) if self . num_support is not None : if isinstance ( self . num_support , int ) : if any ( self . num_support + num_query > images_per_class ) : raise ValueError ( 'Some classes do not have enough examples.' ) num_support = self . num_support else : start , end = self . num_support if any ( end + num_query > images_per_class ) : raise ValueError ( 'The range provided for uniform sampling of the ' 'number of support examples per class is not valid: ' 'some classes do not have enough examples.' ) num_support = self . _rng . randint ( low = start , high = end + 1 ) num_support_per_class = [ num_support for _ in class_ids ] else : num_remaining_per_class = images_per_class - num_query support_set_size = sample_support_set_size ( num_remaining_per_class , self . max_support_size_contrib_per_class , max_support_set_size = self . max_support_set_size , rng = self . _rng ) num_support_per_class = sample_num_support_per_class ( images_per_class , num_remaining_per_class , support_set_size , min_log_weight = self . min_log_weight , max_log_weight = self . max_log_weight , rng = self . _rng ) return tuple ( ( class_id , num_support , num_query ) for class_id , num_support in zip ( class_ids , num_support_per_class ) )