code: def _convert_label(label, convert_labels_to_binary=False):
      """Converts the label to 1D and optionally binarizes it.
  
      Args:
        label: A tensor of shape [list_size, 1].
        convert_labels_to_binary: A boolean to indicate whether to use binary label.
  
      Returns:
        A tensor of shape [list_size].
      """
      if len(tf.shape(label)) > 1:
          label = tf.cast(tf.squeeze(label, axis=-1), tf.float32)
      if convert_labels_to_binary:
          label = tf.where(
              tf.greater(label, 0.0), tf.ones_like(label), label
          )
      return label
  
imports: import dataclasses
  from typing import Callable, Dict, Mapping, Optional, Tuple, Union
  import tensorflow
  from tensorflow_ranking.python import data
  from tensorflow_ranking.python.keras import losses
  from tensorflow_ranking.python.keras import metrics
  from tensorflow_ranking.python.keras import model
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_label(label, convert_labels_to_binary) and returns: label