class_docstr: Util to build a SampleBatch incrementally.
  
  For efficiency, SampleBatches hold values in column form (as arrays).
  However, it is useful to add data one row (dict) at a time.
class_docstr_tok: ["Util","to","build","a","SampleBatch","incrementally",".","For","efficiency",",","SampleBatches","hold","values","in","column","form","(","as","arrays",")",".","However",",","it","is","useful","to","add","data","one","row","(","dict",")","at","a","time","."]
docstr: Returns a sample batch including all previously added values.
docstr_tok: ["Returns","a","sample","batch","including","all","previously","added","values","."]
code: def build_and_reset(self) -> SampleBatch:
      """Returns a sample batch including all previously added values."""
  
      batch = SampleBatch(
          {k: _to_float_array(v) for k, v in self.buffers.items()}
      )
      if SampleBatch.UNROLL_ID not in batch:
          batch[SampleBatch.UNROLL_ID] = np.repeat(
              SampleBatchBuilder._next_unroll_id, batch.count
          )
          SampleBatchBuilder._next_unroll_id += 1
      self.buffers.clear()
      self.count = 0
      return batch
  
imports: import collections
  import logging
  import numpy
  from typing import List, Any, Dict, Optional, TYPE_CHECKING
  from ray.rllib.env.base_env import _DUMMY_AGENT_ID
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.policy.policy import Policy
  from ray.rllib.policy.sample_batch import SampleBatch, MultiAgentBatch
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.deprecation import Deprecated
  from ray.rllib.utils.debug import summarize
  from ray.rllib.utils.deprecation import deprecation_warning
  from ray.rllib.utils.typing import PolicyID, AgentID
  from ray.util.debug import log_once
label_desc: Use image node_id 4 for calling the SampleBatchBuilder obj's underlying member method code with example usage: obj.build_and_reset() and returns: batch