code: def train_func(config):
      # Datasets
      dataset = load_dataset("yelp_review_full")
      tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
  
      def tokenize_function(examples):
          return tokenizer(
              examples["text"], padding="max_length", truncation=True
          )
  
      tokenized_ds = dataset.map(tokenize_function, batched=True)
  
      small_train_ds = (
          tokenized_ds["train"].shuffle(seed=42).select(range(1000))
      )
      small_eval_ds = (
          tokenized_ds["test"].shuffle(seed=42).select(range(1000))
      )
  
      # Model
      model = AutoModelForSequenceClassification.from_pretrained(
          "bert-base-cased", num_labels=5
      )
  
      # Evaluation metrics
      metric = evaluate.load("accuracy")
  
      def compute_metrics(eval_pred):
          logits, labels = eval_pred
          predictions = np.argmax(logits, axis=-1)
          return metric.compute(
              predictions=predictions, references=labels
          )
  
      # Hugging Face Trainer
      training_args = TrainingArguments(
          output_dir="test_trainer",
          evaluation_strategy="epoch",
          report_to="none",
      )
  
      trainer = Trainer(
          model=model,
          args=training_args,
          train_dataset=small_train_ds,
          eval_dataset=small_eval_ds,
          compute_metrics=compute_metrics,
      )
  
      # [2] Report metrics and checkpoints to Ray Train
      # ===============================================
      trainer.add_callback(RayTrainReportCallback())
  
      # [3] Prepare your trainer for Ray Data integration
      # =================================================
      trainer = prepare_trainer(trainer)
  
      # Start Training
      trainer.train()
  
file_path: ray/python/ray/train/examples/transformers/transformers_torch_trainer_basic.py
imports: import evaluate
  import numpy
  from datasets import load_dataset
  from transformers import AutoModelForSequenceClassification, AutoTokenizer, Trainer, TrainingArguments
  from ray.train import ScalingConfig
  from ray.train.huggingface.transformers import RayTrainReportCallback, prepare_trainer
  from ray.train.torch import TorchTrainer
label_desc: Use image node_id 1 for calling a global function with example usage: train_func(config) and returns: tokenizer, metric