class_docstr: Data object used for all RasaModels.
  
  It contains all features needed to train the models.
  'data' is a mapping of attribute name, e.g. TEXT, INTENT, etc., and feature name,
  e.g. SENTENCE, SEQUENCE, etc., to a list of feature arrays representing the actual
  features.
  'label_key' and 'label_sub_key' point to the labels inside 'data'. For
  example, if your intent labels are stored under INTENT -> IDS, 'label_key' would
  be "INTENT" and 'label_sub_key' would be "IDS".
class_docstr_tok: ["Data","object","used","for","all","RasaModels",".","It","contains","all","features","needed","to","train","the","models",".","'data","'","is","a","mapping","of","attribute","name",",","e.g",".","TEXT",",","INTENT",",","etc.",",","and","feature","name",",","e.g",".","SENTENCE",",","SEQUENCE",",","etc.",",","to","a","list","of","feature","arrays","representing","the","actual","features",".","'label_key","'","and","'label_sub_key","'","point","to","the","labels","inside","'data","'",".","For","example",",","if","your","intent","labels","are","stored","under","INTENT","-",">","IDS",",","'label_key","'","would","be","``","INTENT","''","and","'label_sub_key","'","would","be","``","IDS","''","."]
docstr: Adds a feature array of lengths of sequences to data under given key.
  
  Args:
      key: The key to add the lengths to
      sub_key: The sub-key to add the lengths to
      from_key: The key to take the lengths from
      from_sub_key: The sub-key to take the lengths from
docstr_tok: ["Adds","a","feature","array","of","lengths","of","sequences","to","data","under","given","key",".","Args",":","key",":","The","key","to","add","the","lengths","to","sub_key",":","The","sub-key","to","add","the","lengths","to","from_key",":","The","key","to","take","the","lengths","from","from_sub_key",":","The","sub-key","to","take","the","lengths","from"]
code: def add_lengths(
      self, key: Text, sub_key: Text, from_key: Text, from_sub_key: Text
  ) -> None:
      """Adds a feature array of lengths of sequences to data under given key.
  
      Args:
          key: The key to add the lengths to
          sub_key: The sub-key to add the lengths to
          from_key: The key to take the lengths from
          from_sub_key: The sub-key to take the lengths from
      """
      if not self.data.get(from_key) or not self.data.get(
          from_key, {}
      ).get(from_sub_key):
          return
  
      self.data[key][sub_key] = []
  
      for features in self.data[from_key][from_sub_key]:
          if len(features) == 0:
              continue
  
          if features.number_of_dimensions == 4:
              lengths = FeatureArray(
                  ragged_array_to_ndarray(
                      [
                          # add one more dim so that dialogue dim
                          # would be a sequence
                          np.array([[[x.shape[0]]] for x in _features])
                          for _features in features
                      ]
                  ),
                  number_of_dimensions=4,
              )
          else:
              lengths = FeatureArray(
                  np.array([x.shape[0] for x in features]),
                  number_of_dimensions=1,
              )
          self.data[key][sub_key].extend([lengths])
          break
  
imports: import logging
  from typing import Optional, DefaultDict, Dict, Iterable, Text, List, Tuple, Any, Union, NamedTuple, ItemsView, overload, cast
  from collections import defaultdict, OrderedDict
  import numpy
  import scipy.sparse
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 18 for calling the RasaModelData obj's underlying member method code with example usage: obj.add_lengths(key, sub_key, from_key, from_sub_key) without return types