code: def get_channel_index(data_format: str) -> int:
      """Returns the channel index when given a valid data format.
  
      Args:
        data_format: String, the data format to get the channel index from. Valid
          data formats are spatial (e.g.`NCHW`), sequential (e.g. `BTHWD`),
          `channels_first` and `channels_last`).
  
      Returns:
        The channel index as an int - either 1 or -1.
  
      Raises:
        ValueError: If the data format is unrecognised.
      """
      if data_format == "channels_first":
          return 1
      if data_format == "channels_last":
          return -1
      if _SPATIAL_CHANNELS_FIRST.match(data_format):
          return 1
      if _SPATIAL_CHANNELS_LAST.match(data_format):
          return -1
      if _SEQUENTIAL.match(data_format):
          return -1
      raise ValueError(
          "Unable to extract channel information from '{}'. Valid data formats are "
          "spatial (e.g.`NCHW`), sequential (e.g. `BTHWD`), `channels_first` and "
          "`channels_last`).".format(data_format)
      )
  
imports: import collections.abc
  import functools
  import inspect
  import re
  import threading
  from typing import Any, Callable, Dict, Generic, Optional, Sequence, Tuple, TypeVar, Union
  from absl import logging
  from sonnet.src import initializers
  import tabulate
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: get_channel_index(data_format) and returns: int, unknown, int, unknown, unknown