class_docstr: Training callback class. 
class_docstr_tok: ["Training","callback","class","."]
docstr: Training callback applied after every training step.
  
  Parameters
  -----------
  step
      Current experience step.
  update
      Current update step. The ration between the number experience steps and the number of training updates is
      bound to 1.
  model
      CounterfactualRL explainer. All the parameters defined in
      :py:data:`alibi.explainers.cfrl_base.DEFAULT_BASE_PARAMS` can be accessed through `model.params`.
  sample
      Dictionary of samples used for an update which contains
  
          - ``'X'`` : ``np.ndarray`` - input instances.
  
          - ``'Y_m'`` : ``np.ndarray`` - predictor outputs for the input instances.
  
          - ``'Y_t'`` : ``np.ndarray`` - target outputs.
  
          - ``'Z'`` : ``np.ndarray`` - input embeddings.
  
          - ``'Z_cf_tilde'`` : ``np.ndarray`` - noised counterfactual embeddings.
  
          - ``'X_cf_tilde'`` : ``np.ndarray`` - noised counterfactual instances obtained ofter decoding the                 noised counterfactual embeddings `Z_cf_tilde` and apply post-processing functions.
  
          - ``'C'`` : ``Optional[np.ndarray]`` - conditional vector.
  
          - ``'R_tilde'`` : ``np.ndarray`` - reward obtained for the noised counterfactual instances.
  
          - ``'Z_cf'`` : ``np.ndarray`` - counterfactual embeddings.
  
          - ``'X_cf'`` : ``np.ndarray`` - counterfactual instances obtained after decoding the counterfactual                 embeddings `Z_cf` and apply post-processing functions.
  losses
      Dictionary of losses which contains
  
          - ``'loss_actor'`` : ``Callable`` - actor network loss.
  
          - ``'loss_critic'`` : ``Callable`` - critic network loss.
  
          - ``'sparsity_loss'`` : ``Callable`` - sparsity loss for the                 :py:class:`alibi.explainers.cfrl_base.CounterfactualRL` class.
  
          - ``'sparsity_num_loss'`` : ``Callable`` - numerical features sparsity loss for the                 :py:class:`alibi.explainers.cfrl_tabular.CounterfactualRLTabular` class.
  
          - ``'sparsity_cat_loss'`` : ``Callable`` - categorical features sparsity loss for the                 :py:class:`alibi.explainers.cfrl_tabular.CounterfactualRLTabular` class.
  
          - ``'consistency_loss'`` : ``Callable`` - consistency loss if used.
code: def __call__(
      self,
      step: int,
      update: int,
      model: CounterfactualRL,
      sample: Dict[str, np.ndarray],
      losses: Dict[str, float],
  ) -> None:
      """
          Training callback applied after every training step.
  
          Parameters
          -----------
          step
              Current experience step.
          update
              Current update step. The ration between the number experience steps and the number of training updates is
              bound to 1.
          model
              CounterfactualRL explainer. All the parameters defined in
              :py:data:`alibi.explainers.cfrl_base.DEFAULT_BASE_PARAMS` can be accessed through `model.params`.
          sample
              Dictionary of samples used for an update which contains
  
                  - ``'X'`` : ``np.ndarray`` - input instances.
  
                  - ``'Y_m'`` : ``np.ndarray`` - predictor outputs for the input instances.
  
                  - ``'Y_t'`` : ``np.ndarray`` - target outputs.
  
                  - ``'Z'`` : ``np.ndarray`` - input embeddings.
  
                  - ``'Z_cf_tilde'`` : ``np.ndarray`` - noised counterfactual embeddings.
  
                  - ``'X_cf_tilde'`` : ``np.ndarray`` - noised counterfactual instances obtained ofter decoding the \
                  noised counterfactual embeddings `Z_cf_tilde` and apply post-processing functions.
  
                  - ``'C'`` : ``Optional[np.ndarray]`` - conditional vector.
  
                  - ``'R_tilde'`` : ``np.ndarray`` - reward obtained for the noised counterfactual instances.
  
                  - ``'Z_cf'`` : ``np.ndarray`` - counterfactual embeddings.
  
                  - ``'X_cf'`` : ``np.ndarray`` - counterfactual instances obtained after decoding the counterfactual \
                  embeddings `Z_cf` and apply post-processing functions.
          losses
              Dictionary of losses which contains
  
                  - ``'loss_actor'`` : ``Callable`` - actor network loss.
  
                  - ``'loss_critic'`` : ``Callable`` - critic network loss.
  
                  - ``'sparsity_loss'`` : ``Callable`` - sparsity loss for the \
                  :py:class:`alibi.explainers.cfrl_base.CounterfactualRL` class.
  
                  - ``'sparsity_num_loss'`` : ``Callable`` - numerical features sparsity loss for the \
                  :py:class:`alibi.explainers.cfrl_tabular.CounterfactualRLTabular` class.
  
                  - ``'sparsity_cat_loss'`` : ``Callable`` - categorical features sparsity loss for the \
                  :py:class:`alibi.explainers.cfrl_tabular.CounterfactualRLTabular` class.
  
                  - ``'consistency_loss'`` : ``Callable`` - consistency loss if used.
          """
      pass
  
imports: import logging
  import os
  from abc import ABC, abstractmethod
  from copy import deepcopy
  from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Tuple, Union, cast
  import numpy
  from tqdm import tqdm
  from alibi.api.defaults import DEFAULT_DATA_CFRL, DEFAULT_META_CFRL
  from alibi.api.interfaces import Explainer, Explanation, FitMixin
  from alibi.explainers.backends.cfrl_base import generate_empty_condition, get_classification_reward, get_hard_distribution, identity_function
  from alibi.utils.frameworks import Framework, has_pytorch, has_tensorflow
label_desc: Use image node_id 1 for calling the Callback obj's underlying member method code with example usage: obj.__call__(step, update, model, sample, losses) without return types