class_docstr: Random Encoder for Efficient Exploration.
  
  Implementation of:
  [1] State entropy maximization with random encoders for efficient
  exploration. Seo, Chen, Shin, Lee, Abbeel, & Lee, (2021).
  arXiv preprint arXiv:2102.09430.
  
  Estimates state entropy using a particle-based k-nearest neighbors (k-NN)
  estimator in the latent space. The state's latent representation is
  calculated using an encoder with randomly initialized parameters.
  
  The entropy of a state is considered as intrinsic reward and added to the
  environment's extrinsic reward for policy optimization.
  Entropy is calculated per batch, it does not take the distribution of
  the entire replay buffer into consideration.
class_docstr_tok: ["Random","Encoder","for","Efficient","Exploration",".","Implementation","of",":","[","1","]","State","entropy","maximization","with","random","encoders","for","efficient","exploration",".","Seo",",","Chen",",","Shin",",","Lee",",","Abbeel",",","&","Lee",",","(","2021",")",".","arXiv","preprint","arXiv:2102.09430",".","Estimates","state","entropy","using","a","particle-based","k-nearest","neighbors","(","k-NN",")","estimator","in","the","latent","space",".","The","state","'s","latent","representation","is","calculated","using","an","encoder","with","randomly","initialized","parameters",".","The","entropy","of","a","state","is","considered","as","intrinsic","reward","and","added","to","the","environment","'s","extrinsic","reward","for","policy","optimization",".","Entropy","is","calculated","per","batch",",","it","does","not","take","the","distribution","of","the","entire","replay","buffer","into","consideration","."]
docstr: Calculate states' embeddings and add it to SampleBatch.
docstr_tok: ["Calculate","states","'","embeddings","and","add","it","to","SampleBatch","."]
code: def _postprocess_tf(self, policy, sample_batch, tf_sess):
      """Calculate states' embeddings and add it to SampleBatch."""
      if self.framework == "tf":
          obs_embeds = tf_sess.run(
              self._obs_embeds,
              feed_dict={self._obs_ph: sample_batch[SampleBatch.OBS]},
          )
      else:
          obs_embeds = tf.stop_gradient(
              self._encoder_net(
                  {SampleBatch.OBS: sample_batch[SampleBatch.OBS]}
              )[0]
          ).numpy()
      sample_batch[SampleBatch.OBS_EMBEDS] = obs_embeds
      return sample_batch
  
imports: from gymnasium.spaces import Box, Discrete, Space
  import numpy
  from typing import List, Optional, Union
  from ray.rllib.models.action_dist import ActionDistribution
  from ray.rllib.models.catalog import ModelCatalog
  from ray.rllib.models.modelv2 import ModelV2
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.annotations import override, PublicAPI
  from ray.rllib.utils.exploration.exploration import Exploration
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.from_config import from_config
  from ray.rllib.utils.tf_utils import get_placeholder
  from ray.rllib.utils.typing import FromConfigSpec, ModelConfigDict, TensorType
label_desc: Use image node_id 4 for calling the RE3 obj's underlying member method code with example usage: obj._postprocess_tf(policy, sample_batch, tf_sess) and returns: sample_batch