class_docstr: Collects samples for one agent in one trajectory (episode).
  
  The agent may be part of a multi-agent environment. Samples are stored in
  lists including some possible automatic "shift" buffer at the beginning to
  be able to save memory when storing things like NEXT_OBS, PREV_REWARDS,
  etc.., which are specified using the trajectory view API.
docstr: Returns a SampleBatch from the given data dictionary. Also updates the
  sequence information based on the max_seq_len.
docstr_tok: ["Returns","a","SampleBatch","from","the","given","data","dictionary",".","Also","updates","the","sequence","information","based","on","the","max_seq_len","."]
code: def _get_sample_batch(
      self, batch_data: Dict[str, TensorType]
  ) -> SampleBatch:
      """Returns a SampleBatch from the given data dictionary. Also updates the
      sequence information based on the max_seq_len."""
  
      # Due to possible batch-repeats > 1, columns in the resulting batch
      # may not all have the same batch size.
      batch = SampleBatch(batch_data, is_training=self.training)
  
      # Adjust the seq-lens array depending on the incoming agent sequences.
      if self.is_policy_recurrent:
          seq_lens = []
          max_seq_len = self.max_seq_len
          count = batch.count
          while count > 0:
              seq_lens.append(min(count, max_seq_len))
              count -= max_seq_len
          batch["seq_lens"] = np.array(seq_lens)
          batch.max_seq_len = max_seq_len
  
      return batch
  
imports: import copy
  import logging
  import math
  from typing import Any, Dict, List, Optional
  import numpy
  import tree
  from gymnasium.spaces import Space
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.policy.view_requirement import ViewRequirement
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.spaces.space_utils import flatten_to_single_ndarray, get_dummy_batch_for_space
  from ray.rllib.utils.typing import EpisodeID, EnvID, TensorType, ViewRequirementsDict
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 10 for calling the AgentCollector obj's underlying member method code with example usage: obj._get_sample_batch(batch_data) and returns: batch