class_docstr: ``BaseBackend`` is the base class for all backends.
  All explainability implementations should extend this abstract class
  and implement the methods marked as abstract.
docstr: This function allows to format and aggregate contributions in the right format
  (pd.DataFrame or list of pd.DataFrame).
  
  If a preprocessing exists, it also uses it to change the contributions if needed.
  
  Parameters
  ----------
  x : pd.DataFrame
      The dataframe of observations used by the model.
  contributions : pd.DataFrame or np.array or list of pd.DataFrame or list of np.array
      Local contributions, or list of local contributions.
  
  Returns
  -------
  contributions : pd.DataFrame or list of pd.DataFrame
      Contributions formatted and aggregated
docstr_tok: ["This","function","allows","to","format","and","aggregate","contributions","in","the","right","format","(","pd.DataFrame","or","list","of","pd.DataFrame",")",".","If","a","preprocessing","exists",",","it","also","uses","it","to","change","the","contributions","if","needed",".","Parameters","--","--","--","--","--","x",":","pd.DataFrame","The","dataframe","of","observations","used","by","the","model",".","contributions",":","pd.DataFrame","or","np.array","or","list","of","pd.DataFrame","or","list","of","np.array","Local","contributions",",","or","list","of","local","contributions",".","Returns","--","--","--","-","contributions",":","pd.DataFrame","or","list","of","pd.DataFrame","Contributions","formatted","and","aggregated"]
code: def format_and_aggregate_local_contributions(
      self,
      x: pd.DataFrame,
      contributions: Union[
          pd.DataFrame, np.array, List[pd.DataFrame], List[np.array]
      ],
  ) -> Union[pd.DataFrame, List[pd.DataFrame]]:
      """
      This function allows to format and aggregate contributions in the right format
      (pd.DataFrame or list of pd.DataFrame).
  
      If a preprocessing exists, it also uses it to change the contributions if needed.
  
      Parameters
      ----------
      x : pd.DataFrame
          The dataframe of observations used by the model.
      contributions : pd.DataFrame or np.array or list of pd.DataFrame or list of np.array
          Local contributions, or list of local contributions.
  
      Returns
      -------
      contributions : pd.DataFrame or list of pd.DataFrame
          Contributions formatted and aggregated
      """
      contributions = adapt_contributions(self._case, contributions)
      self.state = choose_state(contributions)
      check_contribution_object(
          self._case, self._classes, contributions
      )
      contributions = self.state.validate_contributions(
          contributions, x
      )
      contributions_cols = (
          contributions.columns.to_list()
          if isinstance(contributions, pd.DataFrame)
          else contributions[0].columns.to_list()
      )
      if _needs_preprocessing(
          contributions_cols, x, self.preprocessing
      ):
          contributions = self._apply_preprocessing(contributions)
      return contributions
  
file_path: shapash/shapash/backend/base_backend.py
imports: from abc import ABC, abstractmethod
  from typing import Any, List, Optional, Union
  import pandas
  import numpy
  from shapash.utils.check import check_model, check_contribution_object
  from shapash.utils.transform import adapt_contributions, get_preprocessing_mapping
  from shapash.utils.utils import choose_state
label_desc: Use image node_id 5 for calling the BaseBackend obj's underlying member method code with example usage: obj.format_and_aggregate_local_contributions(x, contributions) and returns: contributions