def METHOD_NAME(objs, meta=None, update_fields=None, exclude_fields=None,
                using='default', batch_size=None, pk_field='pk'):
    assert batch_size is None or batch_size > 0
    # force to retrieve objs from the DB at the beginning,
    # to avoid multiple subsequent queries
    objs = list(objs)
    if not objs:
        return
    batch_size = batch_size or len(objs)
    if meta:
        fields = get_fields(update_fields, exclude_fields, meta)
    else:
        meta = objs[0]._meta
        if update_fields is not None:
            fields = get_fields(update_fields, exclude_fields, meta, objs[0])
        else:
            fields = None
    if fields is not None and len(fields) == 0:
        return
    if pk_field == 'pk':
        pk_field = meta.get_field(meta.pk.name)
    else:
        pk_field = meta.get_field(pk_field)
    connection = connections[using]
    query = UpdateQuery(meta.model)
    compiler = query.get_compiler(connection=connection)
    template = '"{column}" = CAST(CASE "{pk_column}" {cases}ELSE "{column}" END AS {type})'
    case_template = "WHEN %s THEN {} "
    lenpks = 0
    for objs_batch in grouper(objs, batch_size):
        pks = []
        parameters = defaultdict(list)
        placeholders = defaultdict(list)
        for obj in objs_batch:
            pk_value, _ = _as_sql(obj, pk_field, query, compiler, connection)
            pks.append(pk_value)
            loaded_fields = fields or get_fields(update_fields, exclude_fields, meta, obj)
            for field in loaded_fields:
                value, placeholder = _as_sql(obj, field, query, compiler, connection)
                parameters[field].extend(flatten([pk_value, value], types=tuple))
                placeholders[field].append(placeholder)
        values = ', '.join(
            template.format(
                column=field.column,
                pk_column=pk_field.column,
                cases=(case_template*len(placeholders[field])).format(*placeholders[field]),
                type=_get_db_type(field, connection=connection),
            )
            for field in parameters.keys()
        )
        parameters = flatten(parameters.values(), types=list)
        parameters.extend(pks)
        n_pks = len(pks)
        del pks
        dbtable = '"{}"'.format(meta.db_table)
        in_clause = '"{pk_column}" in ({pks})'.format(
            pk_column=pk_field.column,
            pks=', '.join(itertools.repeat('%s', n_pks)),
        )
        sql = 'UPDATE {dbtable} SET {values} WHERE {in_clause}'.format(   # nosec
            dbtable=dbtable,
            values=values,
            in_clause=in_clause,
        )
        del values
        lenpks += n_pks
        connection.cursor().execute(sql, parameters)
    return lenpks