class_docstr: Wrapper for calling the `R hts package
  <https://www.r-pkg.org/pkg/hts>`_.
  
  In order to use it you need to install R and rpy2. You also need the R `hts` package which
  can be installed by running:
  
      R -e 'install.packages(c("hts"), repos="https://cloud.r-project.org")'
  
  Parameters
  ----------
  freq
      The granularity of the time series (e.g. '1H')
  prediction_length
      Number of time points to be predicted.
  is_hts
      Is the time series a hierarchical one as opposed to a grouped time series. # noqa
  target_dim
      The dimension (size) of the multivariate target time series.
  num_bottom_ts
      Number of bottom time series in the hierarchy.
  nodes
      Node structure representing the hierarchichy as defined in the hts package.
      To know the exact strucutre of nodes see the help:
      Hierarhical: https://stackoverflow.com/questions/13579292/how-to-use-hts-with-multi-level-hierarchies
      Grouped: https://robjhyndman.com/hyndsight/gts/
  nonnegative
      Is the target non-negative?
  method_name
      Hierarchical forecasting or reconciliation method to be used; mutst be one of:
      "naive_bottom_up", "middle_out_w_forecasts_proportions", "top_down_w_average_historical_proportions",
      "top_down_w_proportions_of_the_historical_averages", "top_down_w_forecasts_proportions", "mint", "erm"
  fmethod
      The forecasting method to be used for generating base forecasts (i.e., un-reconciled forecasts).
  period
      The period to be used (this is called `frequency` in the R forecast
      package), result to a tentative reasonable default if not specified
      (for instance 24 for hourly freq '1H')
  trunc_length
      Maximum history length to feed to the model (some models become slow
      with very long series).
  params
      Parameters to be used when calling the forecast method default.
      Note that, as `output_type`, only 'samples' is supported currently.
  level
      Level of hierarchy to be used as reference for `middle out` reconciliation (i.e. level=1 means that the level
      below the highest one will be used as reference to compute the forecasts of all the other levels). This value
      is required only for `middle out`.
  numcores
      Number of cores to be used for parallelization of ERM. If not provided, all cores will be used.
class_docstr_tok: ["Wrapper","for","calling","the","`","R","hts","package","<","https",":","\/\/www.r-pkg.org\/pkg\/hts",">","`","_",".","In","order","to","use","it","you","need","to","install","R","and","rpy2",".","You","also","need","the","R","`","hts","`","package","which","can","be","installed","by","running",":","R","-e","'install.packages","(","c","(","``","hts","''",")",",","repos=","''","https",":","\/\/cloud.r-project.org","''",")","'","Parameters","--","--","--","--","--","freq","The","granularity","of","the","time","series","(","e.g",".","'1H","'",")","prediction_length","Number","of","time","points","to","be","predicted",".","is_hts","Is","the","time","series","a","hierarchical","one","as","opposed","to","a","grouped","time","series",".","#","noqa","target_dim","The","dimension","(","size",")","of","the","multivariate","target","time","series",".","num_bottom_ts","Number","of","bottom","time","series","in","the","hierarchy",".","nodes","Node","structure","representing","the","hierarchichy","as","defined","in","the","hts","package",".","To","know","the","exact","strucutre","of","nodes","see","the","help",":","Hierarhical",":","https",":","\/\/stackoverflow.com\/questions\/13579292\/how-to-use-hts-with-multi-level-hierarchies","Grouped",":","https",":","\/\/robjhyndman.com\/hyndsight\/gts\/","nonnegative","Is","the","target","non-negative","?","method_name","Hierarchical","forecasting","or","reconciliation","method","to","be","used",";","mutst","be","one","of",":","``","naive_bottom_up","''",",","``","middle_out_w_forecasts_proportions","''",",","``","top_down_w_average_historical_proportions","''",",","``","top_down_w_proportions_of_the_historical_averages","''",",","``","top_down_w_forecasts_proportions","''",",","``","mint","''",",","``","erm","''","fmethod","The","forecasting","method","to","be","used","for","generating","base","forecasts","(","i.e.",",","un-reconciled","forecasts",")",".","period","The","period","to","be","used","(","this","is","called","`","frequency","`","in","the","R","forecast","package",")",",","result","to","a","tentative","reasonable","default","if","not","specified","(","for","instance","24","for","hourly","freq","'1H","'",")","trunc_length","Maximum","history","length","to","feed","to","the","model","(","some","models","become","slow","with","very","long","series",")",".","params","Parameters","to","be","used","when","calling","the","forecast","method","default",".","Note","that",",","as","`","output_type","`",",","only","'samples","'","is","supported","currently",".","level","Level","of","hierarchy","to","be","used","as","reference","for","`","middle","out","`","reconciliation","(","i.e",".","level=1","means","that","the","level","below","the","highest","one","will","be","used","as","reference","to","compute","the","forecasts","of","all","the","other","levels",")",".","This","value","is","required","only","for","`","middle","out","`",".","numcores","Number","of","cores","to","be","used","for","parallelization","of","ERM",".","If","not","provided",",","all","cores","will","be","used","."]
code: def _forecast_dict_to_obj(
      self,
      forecast_dict: Dict,
      forecast_start_date: pd.Timestamp,
      item_id: Optional[str],
      info: Optional[Dict],
  ) -> SampleForecast:
      samples = np.array(forecast_dict["samples"])
  
      expected_shape = (
          self.params["num_samples"],
          self.prediction_length,
          self.target_dim,
      )
      assert (
          samples.shape == expected_shape
      ), f"Expected shape {expected_shape} but found {samples.shape}"
  
      return SampleForecast(
          samples,
          start_date=forecast_start_date,
          info=info,
          item_id=item_id,
      )
  
file_path: gluonts/src/gluonts/ext/r_forecast/_hierarchical_predictor.py
imports: from typing import Dict, List, Optional
  import numpy
  import pandas
  from gluonts.core.component import validated
  from gluonts.model.forecast import SampleForecast
  from .None import RBasePredictor
label_desc: Use image node_id 4 for calling the RHierarchicalForecastPredictor obj's underlying member method code with example usage: obj._forecast_dict_to_obj(forecast_dict, forecast_start_date, item_id, info) and returns: SampleForecast