code: def generate_meta_and_test_tasks(
      num_datapoints, num_meta, num_test, N
  ):
      """Generates meta-task datasets {D_i} = {x_i, y_i} and target task training
      and test data {\tilde{x}, \tilde{y}} (Fortuin and Rätsch, 2019).
  
      Args:
          num_datapoints: The number of training points, \tilde{n} in Table S1.
          num_meta: The number of meta-tasks ("sampled functions").
          num_test: The number of test tasks ("unseen functions").
          N: Number of sampled data points per function.
  
      Returns:
          A tuple (meta, test) where
          - meta: List of num_meta pairs of arrays (X, Y) of size (n, 1) each.
          - test: List of num_test pairs of pairs of arrays of sizes
                  (((num_datapoints, 1), (num_datapoints, 1)),
                   ((N - num_datapoints, 1), (N - num_datapoints, 1))).
      """
      Xs, F = generate_data(num_functions=num_meta + num_test, N=N)
      meta = []
      sd = 1e-1  # Standard deviation for normally-distributed observation noise.
      for i in range(num_meta):
          # We always use all data points of the curve to train the mean function,
          # i.e. n_i = N.
          noise = sd * np.random.randn(N, 1)
          Y = F[:, i][:, None] + noise
          meta.append((Xs, Y))
      test = []
      rand_indices = np.random.permutation(N)
      train_i = sorted(rand_indices[:num_datapoints])
      test_i = sorted(rand_indices[num_datapoints:])
      for i in range(num_test):
          # Form target training set, \tilde{D}_{train} (see Figure 1).
          noise = sd * np.random.randn(num_datapoints, 1)
          train_X = Xs[train_i]
          train_Y = F[train_i, num_meta + i][:, None] + noise
          # Form target test set, \tilde{D}_{test}, which is disjoint from the
          # target traininig set as it is in the original implementation.
          test_X = Xs[test_i]
          test_Y = F[test_i, num_meta + i][:, None]
          # Form target tasks' datasets \tilde{D} as a pair of pairs,
          # (\tilde{X}, \tilde{Y}) and (\tilde{X}*, \tilde{Y}*).
          test.append(((train_X, train_Y), (test_X, test_Y)))
      return meta, test
  
file_path: GPflow/notebooks/tailor/external-mean-function.pct.py
imports: import matplotlib.pyplot
  import numpy
  import tensorflow
  import gpflow
  from gpflow.ci_utils import reduce_in_tests
  from gpflow.kernels import RBF
  from gpflow.models import GPR
  from gpflow.config import default_float
  from gpflow import set_trainable
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: generate_meta_and_test_tasks(num_datapoints, num_meta, num_test, N) and returns: meta,  test