code: def convert_data_format(data_format, ndim):
      if data_format == "channels_last":
          if ndim == 3:
              return "NWC"
          elif ndim == 4:
              return "NHWC"
          elif ndim == 5:
              return "NDHWC"
          else:
              raise ValueError(
                  f"Input rank: {ndim} not supported. We only support "
                  "input rank 3, 4 or 5."
              )
      elif data_format == "channels_first":
          if ndim == 3:
              return "NCW"
          elif ndim == 4:
              return "NCHW"
          elif ndim == 5:
              return "NCDHW"
          else:
              raise ValueError(
                  f"Input rank: {ndim} not supported. We only support "
                  "input rank 3, 4 or 5."
              )
      else:
          raise ValueError(
              f"Invalid data_format: {data_format}. We only support "
              '"channels_first" or "channels_last"'
          )
  
file_path: tensorflow/tensorflow/python/layers/utils.py
imports: from tensorflow.python.framework import smart_cond
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import variables
label_desc: Use image node_id 1 for calling a global function with example usage: convert_data_format(data_format, ndim) and returns: str, str, str, str, str, str