class_docstr: A TFGraphRecordDecoder that decodes ExampleListWithContext proto.
class_docstr_tok: ["A","TFGraphRecordDecoder","that","decodes","ExampleListWithContext","proto","."]
code: def decode_record(self, records):
      example_features = list(self._example_features)
      if self._label_feature is not None:
          example_features.append(self._label_feature)
      # Our ELWC parser is based on struct2tensor
      # (https://github.com/google/struct2tensor).
      result = parse_elwc_with_struct2tensor(
          records,
          self._context_features,
          example_features,
          size_feature_name=self._size_feature_name,
      )
  
      if self._label_feature is not None:
          # Cast label into float32.
          # TF-Ranking assumes the label is float32.
          result[self._label_feature.name] = tf.cast(
              result[self._label_feature.name], tf.float32
          )
          # TF-Ranking library assumes the label is of rank 2.
          # For example, the label ragged tensor of a batch of 2 ELWCs, with 2 and 1
          # examples respectively looks like:
          # [[[elwc1_e1], [elwc1_e2]], [[elwc2_e1]]]
          # However,
          # [[elwc1_e1, elwc1_e2], [elwc2_e1]]
          # is expected.
          # Because we know that each document has exactly one label (the innermost
          # dimension is of size 1), we could use tf.squeeze(..., axis=2), however
          # merge_dims() of a RaggedTensor is faster and equivalent in this case.
          result[self._label_feature.name] = result[
              self._label_feature.name
          ].merge_dims(1, 2)
      return result
  
file_path: tfx/tfx/examples/ranking/struct2tensor_parsing_utils.py
imports: import itertools
  from typing import Dict, List, Optional, Union
  from struct2tensor import calculate
  from struct2tensor import calculate_options
  from struct2tensor import path
  from struct2tensor import prensor_util
  from struct2tensor.expression_impl import proto
  import tensorflow
  from tfx_bsl.public import tfxio
  from tensorflow_serving.apis import input_pb2
label_desc: Use image node_id 2 for calling the ELWCDecoder obj's underlying member method code with example usage: obj.decode_record(records) and returns: result