code: def process(task, bucket, **kwargs):
      """Returns valid transformed bucket from bucket."""
      transform_cid_to_examples = {}
      for example in bucket:
          transform_cid = (example[1], example[2])
          if transform_cid not in transform_cid_to_examples:
              transform_cid_to_examples[transform_cid] = []
          transform_cid_to_examples[transform_cid].append(example)
  
      processed_bucket = []
      # careful below it will return a bucket sorted by corpora
      # but we sort by length later and shuffle batches
      for (
          transform,
          cid,
      ), sub_bucket in transform_cid_to_examples.items():
          transf_bucket = transform.batch_apply(
              sub_bucket,
              is_train=(task == CorpusTask.TRAIN),
              corpus_name=cid,
          )
          for example, transform, cid in transf_bucket:
              example = clean_example(example)
              if len(example["src"]["src"]) > 0:
                  processed_bucket.append(example)
  
          # at this point an example looks like:
          # {'src': {'src': ..., 'feats': [....]},
          #  'tgt': {'tgt': ...},
          #  'src_original': ['tok1', ...'tokn'],
          #  'tgt_original': ['tok1', ...'tokm'],
          #  'cid': corpus id
          #  'cid_line_number' : cid line number
          #  'align': ...,
          # }
      if len(processed_bucket) > 0:
          return processed_bucket
      else:
          return None
  
file_path: OpenNMT-py/onmt/inputters/text_utils.py
imports: import torch
  import pyonmttok
  from onmt.constants import DefaultTokens, CorpusTask, ModelTask
  from torch.nn.utils.rnn import pad_sequence
  from onmt.utils.logging import logger
  from collections import Counter
label_desc: Use image node_id 5 for calling a global function with example usage: process(task, bucket) and returns: processed_bucket, None