def METHOD_NAME(batch: Any, key: Any, value: Any) -> Any:
    """Sets a key value pair in a non-tuple batch."""
    if isinstance(batch, tuple):
        return _batch_set_tuple(batch, key, value)
    try:
        # Check if one can do a __getitem__ before doing a __setitem__ because dicts can
        # do __setitem__ for elements not in the dict and we do not want that.
        # Note for defaultdict and Counter objects, just calling batch[key] for
        # with a new keyword will create a new key, value pair in the object.
        batch[key]
        batch[key] = value
    # The only acceptable TypeErrors are for an object that doesn't have a __setitem__ or a __getitem__,
    # which is TypeError("... object does not support item assignment") and TypeError('.. object is not subscriptable')
    except TypeError as e:
        if 'object does not support item assignment' in str(e) or 'object is not subscriptable' in str(e):
            pass
        else:  # Other type errors should be raised.
            raise e
    else:
        return batch
    try:
        # Make sure batch has key before setting it.
        getattr(batch, key)
        setattr(batch, key, value)
    # If both (setattr or getattr) and __setitem__ raise exceptions then raise both of them.
    except (AttributeError, TypeError) as e:
        raise RuntimeError(
            f'Unable to set key {key} to value {value} on batch {batch}. Please specify a custom set_fn, if necessary.')
    else:
        return batch