class_docstr: A Batch wraps a pyarrow.RecordBatch and provides caching functionality.
  
  This is useful when several different generators need to apply the same
  computation to the same input record batch. A CompositeCombinerStatsGenerator
  instantiates an InputBatch and then passes it to the add_input method of each
  constituent generator. This allows the constituent generators to reuse
  expensive operations that have already been computed by other constituents.
docstr: Returns a numpy array containing the length of each feature list.
  
  If the requested path is not present in the record batch wrapped by the
  InputBatch, the returned array will consist of zeros, and be of length equal
  to the number of rows in the record batch.
  
  Args:
    path: The path for which to return list lengths.
  
  Returns:
    An ndarray containing the lengths of each nested list. The returned
    ndarray will be of shape (N,) where N is the number of rows in the
    referenced array (or in the record batch, if the path cannot be found).
  
  Raises:
    ValueError: When the referenced array is neither a ListArray nor null.
docstr_tok: ["Returns","a","numpy","array","containing","the","length","of","each","feature","list",".","If","the","requested","path","is","not","present","in","the","record","batch","wrapped","by","the","InputBatch",",","the","returned","array","will","consist","of","zeros",",","and","be","of","length","equal","to","the","number","of","rows","in","the","record","batch",".","Args",":","path",":","The","path","for","which","to","return","list","lengths",".","Returns",":","An","ndarray","containing","the","lengths","of","each","nested","list",".","The","returned","ndarray","will","be","of","shape","(","N",",",")","where","N","is","the","number","of","rows","in","the","referenced","array","(","or","in","the","record","batch",",","if","the","path","can","not","be","found",")",".","Raises",":","ValueError",":","When","the","referenced","array","is","neither","a","ListArray","nor","null","."]
code: def list_lengths(self, path: types.FeaturePath) -> np.ndarray:
      """Returns a numpy array containing the length of each feature list.
  
      If the requested path is not present in the record batch wrapped by the
      InputBatch, the returned array will consist of zeros, and be of length equal
      to the number of rows in the record batch.
  
      Args:
        path: The path for which to return list lengths.
  
      Returns:
        An ndarray containing the lengths of each nested list. The returned
        ndarray will be of shape (N,) where N is the number of rows in the
        referenced array (or in the record batch, if the path cannot be found).
  
      Raises:
        ValueError: When the referenced array is neither a ListArray nor null.
      """
      key = ("list_lengths({})", path)
      if key in self._cache:
          return self._cache[key]
      try:
          array, _ = table_util.get_array(
              self._record_batch,
              tfx_bsl_path.ColumnPath(path.steps()),
              return_example_indices=False,
          )
          if pa.types.is_null(array.type):
              lengths = np.full(self._record_batch.num_rows, 0)
          elif not array_util.is_list_like(array.type):
              raise ValueError(
                  "Can only compute list lengths on list arrays, found "
                  "{}".format(array.type)
              )
          else:
              lengths = np.asarray(
                  array_util.ListLengthsFromListArray(array)
              )
      except KeyError:
          lengths = np.full(self._record_batch.num_rows, 0)
      self._cache[key] = lengths
      return lengths
  
file_path: data-validation/tensorflow_data_validation/statistics/generators/input_batch.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import pyarrow
  from tensorflow_data_validation import types
  from tfx_bsl.arrow import array_util
  from tfx_bsl.arrow import path
  from tfx_bsl.arrow import table_util
label_desc: Use image node_id 5 for calling the InputBatch obj's underlying member method code with example usage: obj.list_lengths(path) and returns: lengths, self