code: def get_weight_feature(
      input_record_batch: pa.RecordBatch, weight_column: Text
  ) -> np.ndarray:
      """Gets the weight column from the input record batch.
  
      Args:
        input_record_batch: Input record batch.
        weight_column: Name of the column containing the weight.
  
      Returns:
        A numpy array containing the weights of the examples in the input
        record_batch.
  
      Raises:
        ValueError: If the weight feature is not present in the input record_batch
        or is not a valid weight feature (must be of numeric type and have a
        single value for each example).
      """
      weights_field_index = input_record_batch.schema.get_field_index(
          weight_column
      )
      if weights_field_index < 0:
          raise ValueError(
              'Weight column "{}" not present in the input '
              "record batch.".format(weight_column)
          )
      weights = input_record_batch.column(weights_field_index)
  
      if pa.types.is_null(weights.type):
          raise ValueError(
              'Weight column "{}" cannot be null.'.format(weight_column)
          )
      # Before flattening, check that there is a single value for each example.
      weight_lengths = array_util.ListLengthsFromListArray(
          weights
      ).to_numpy()
      if not np.all(weight_lengths == 1):
          raise ValueError(
              'Weight column "{}" must have exactly one value in each example.'.format(
                  weight_column
              )
          )
      flat_weights = weights.flatten()
      # Before converting to numpy view, check the type (cannot convert string and
      # binary arrays to numpy view).
      flat_weights_type = flat_weights.type
      if not pa.types.is_floating(
          flat_weights_type
      ) and not pa.types.is_integer(flat_weights_type):
          raise ValueError(
              'Weight column "{}" must be of numeric type. Found {}.'.format(
                  weight_column, flat_weights_type
              )
          )
      return np.asarray(flat_weights)
  
file_path: data-validation/tensorflow_data_validation/arrow/arrow_util.py
imports: from typing import Callable, Dict, Iterable, Optional, Text, Tuple
  import numpy
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.utils.example_weight_map import ExampleWeightMap
  from tfx_bsl.arrow import array_util
label_desc: Use image node_id 1 for calling a global function with example usage: get_weight_feature(input_record_batch, weight_column) and returns: np