docs: function saveBatchStateToDynamoDB(batch, context) {
    const task = this;
    const startTime = Date.now();
  
    try {
      const streamConsumerId = batch.streamConsumerId || (batch.key && batch.key.streamConsumerId);
      const shardOrEventID = batch.shardOrEventID || (batch.key && batch.key.shardOrEventID);
  
      // Resolve the stage-qualified table name
      const unqualifiedTableName = getBatchStateTableName(context);
      const tableName = stages.toStageQualifiedResourceName(unqualifiedTableName, context.stage, context);
  
      if (isBlank(streamConsumerId) || isBlank(shardOrEventID)) {
        if (batch.messages.length <= 0 && batch.rejectedMessages.length <= 0 && batch.unusableRecords.length <= 0) {
          context.warn('Skipping save state of an empty batch - ', batch.describe(false));
          return Promise.resolve(undefined);
        }
        const errMsg = `Cannot save state of batch to ${tableName} WITHOUT a complete batch key - streamConsumerId (${streamConsumerId}) & shardOrEventID (${shardOrEventID})`;
        context.error(errMsg, '-', batch.describe(false));
        return Promise.reject(new Error(errMsg));
      }
  
      // Transform the batch into a batch state item to be saved
      const item = toBatchStateItem(batch, context);
  
      if (!item) {
        const errMsg = `Cannot save state of batch to ${tableName}, since no batch state item was resolved`;
        context.error(errMsg, '-', batch.describe(false));
        return Promise.reject(new Error(errMsg));
      }
  
      const dynamoDBDocClient = getDynamoDBDocClient(context);
  
      // Save a batch state item for the entire batch of messages, rejected messages and unusable records to DynamoDB
      return (batch.previouslySaved ?
          updateBatchState(dynamoDBDocClient, tableName, item, batch, context) :
          insertBatchState(dynamoDBDocClient, tableName, item, batch, context)
      ).then(
        result => {
          if (context.traceEnabled) {
            context.trace(`Saved state of batch to ${tableName} -`, batch.describe(false), took(startTime));
          }
          return result;
        },
        err => {
          if (awsErrors.isResourceNotFoundException(err)) {
            const errMsg = `FATAL - Cannot save state of batch, since missing DynamoDB table (${tableName}) - ${err.message}`;
            context.error(errMsg, '-', batch.describe(false), took(startTime), err);
            throw new FatalError(errMsg, err);
          }
          if (awsErrors.isRetryable(err)) {
            const errMsg = `TRANSIENT - Failed to save state of batch to ${tableName} - ${err.message}`;
            context.error(errMsg, '-', batch.describe(false), took(startTime), err);
            if (task) task.revertAttempts(true);
            throw new TransientError(errMsg, err);
          }
          context.error(`Failed to save state of batch to ${tableName} -`, batch.describe(false), took(startTime), err);
          throw err;
        }
      );
  
    } catch (err) {
      context.error('Failed to save state of ', batch.describe(false), took(startTime), err);
      return Promise.reject(err);
    }
  }