code: def _cb_key_val(ctx, param, value):
      """
      click callback to validate `--opt KEY1=VAL1 --opt KEY2=VAL2` and collect
      in a dictionary like the one below, which is what the CLI function receives.
      If no value or `None` is received then an empty dictionary is returned.
  
          {
              'KEY1': 'VAL1',
              'KEY2': 'VAL2'
          }
  
      Note: `==VAL` breaks this as `str.split('=', 1)` is used.
      """
  
      if not value:
          return {}
      else:
          out = {}
          for pair in value:
              if "=" not in pair:
                  raise click.BadParameter(
                      "Invalid syntax for KEY=VAL arg: {}".format(pair)
                  )
              else:
                  k, v = pair.split("=", 1)
                  k = k.lower()
                  v = v.lower()
                  out[k] = (
                      None
                      if v.lower() in ["none", "null", "nil", "nada"]
                      else v
                  )
          return out
  
file_path: rasterio/rasterio/rio/options.py
imports: import logging
  import os
  import re
  import click
  import rasterio
  import rasterio.shutil
  from rasterio._path import _parse_path, _UnparsedPath
label_desc: Use image node_id 1 for calling a global function with example usage: _cb_key_val(ctx, param, value) and returns: dict, out