class_docstr: Data generator with an optional increasing batch size.
class_docstr_tok: ["Data","generator","with","an","optional","increasing","batch","size","."]
docstr: Number of batches in the Sequence.
  
  Returns:
      The number of batches in the Sequence.
docstr_tok: ["Number","of","batches","in","the","Sequence",".","Returns",":","The","number","of","batches","in","the","Sequence","."]
code: def __len__(self) -> int:
      """Number of batches in the Sequence.
  
      Returns:
          The number of batches in the Sequence.
      """
      # data was rebalanced, so need to recalculate number of examples
      num_examples = self.model_data.number_of_examples(self._data)
      batch_size = self._current_batch_size
      # keep last batch only if it has at least half a batch size of examples
      last_batch_half_full = num_examples % batch_size >= math.ceil(
          batch_size / 2
      )
      num_batches = num_examples // batch_size + int(
          last_batch_half_full
      )
      # Return at least 1 if there is an example
      return max(num_batches, int(num_examples > 0))
  
imports: import math
  from typing import List, Union, Text, Optional, Any, Tuple, Dict, cast
  import logging
  import scipy.sparse
  import numpy
  from tensorflow.keras.utils import Sequence
  from rasa.utils.tensorflow.constants import SEQUENCE, BALANCED
  from rasa.utils.tensorflow.model_data import RasaModelData, Data, FeatureArray
label_desc: Use image node_id 2 for calling the RasaBatchDataGenerator obj's underlying member method code with example usage: obj.__len__() and returns: max