class_docstr: VarLenTensorValue encapsulates a batch of varlen dense tensor values.
  
  Attributes:
    values: A np.ndarray of values.
    indices: A np.ndarray of indices.
    dense_shape: A np.ndarray representing the dense shape of the entire tensor.
      Note that each row (i.e. set of values sharing the same value for the
      first / batch dimension) is considered to have its own shape based on the
      presence of values.
class_docstr_tok: ["VarLenTensorValue","encapsulates","a","batch","of","varlen","dense","tensor","values",".","Attributes",":","values",":","A","np.ndarray","of","values",".","indices",":","A","np.ndarray","of","indices",".","dense_shape",":","A","np.ndarray","representing","the","dense","shape","of","the","entire","tensor",".","Note","that","each","row","(","i.e",".","set","of","values","sharing","the","same","value","for","the","first","\/","batch","dimension",")","is","considered","to","have","its","own","shape","based","on","the","presence","of","values","."]
docstr: Converts a collection of variable length dense arrays into a tensor.
  
  Args:
    dense_rows: A sequence of possibly variable length 1D arrays.
  
  Returns:
    A new VarLenTensorValue containing the sparse representation of the
    vertically stacked dense rows. The dense_shape attribute on the result
    will be (num_rows, max_row_len).
docstr_tok: ["Converts","a","collection","of","variable","length","dense","arrays","into","a","tensor",".","Args",":","dense_rows",":","A","sequence","of","possibly","variable","length","1D","arrays",".","Returns",":","A","new","VarLenTensorValue","containing","the","sparse","representation","of","the","vertically","stacked","dense","rows",".","The","dense_shape","attribute","on","the","result","will","be","(","num_rows",",","max_row_len",")","."]
code: def from_dense_rows(
      cls, dense_rows: Iterable[np.ndarray]
  ) -> "VarLenTensorValue":
      """Converts a collection of variable length dense arrays into a tensor.
  
      Args:
        dense_rows: A sequence of possibly variable length 1D arrays.
  
      Returns:
        A new VarLenTensorValue containing the sparse representation of the
        vertically stacked dense rows. The dense_shape attribute on the result
        will be (num_rows, max_row_len).
      """
      rows = []
      index_arrays = []
      max_row_len = 0
      num_rows = 0
      for i, row in enumerate(dense_rows):
          num_rows += 1
          if row.size:
              if row.ndim <= 1:
                  # Add a dimension for unsized numpy array. This will solve the problem
                  # where scalar numpy arrays like np.array(None), np.array(0) can not
                  # be merged with other numpy arrays.
                  row = row.reshape(-1)
                  rows.append(row)
              else:
                  raise ValueError(
                      "Each non-empty dense row should be 1D or scalar but"
                      f" found row with shape {row.shape}."
                  )
              index_arrays.append(
                  np.array([[i, j] for j in range(len(row))])
              )
          max_row_len = max(max_row_len, row.size)
      if index_arrays:
          values = np.concatenate(rows, axis=0)
          indices = np.concatenate(index_arrays, axis=0)
      else:
          # empty case
          values = np.array([])
          indices = np.empty((0, 2))
      dense_shape = np.array([num_rows, max_row_len])
      return cls.__new__(
          cls, values=values, indices=indices, dense_shape=dense_shape
      )
  
imports: import abc
  import datetime
  import operator
  from typing import Any, Callable, Dict, Iterable, List, MutableMapping, NamedTuple, Optional, TypeVar, Tuple, Union
  from apache_beam.utils import shared
  import numpy
  import six
  import tensorflow
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
label_desc: Use image node_id 3 for calling the VarLenTensorValue obj's underlying member method code with example usage: obj.from_dense_rows(cls, dense_rows) and returns: cls