code: def pad_to_size(
      x: np.ndarray, size: int, axis: int = 0, is_right_pad: bool = True
  ):
      """
      Pads `xs` with 0 on the right (default) on the specified axis, which is the
      first axis by default.
      """
  
      pad_length = size - x.shape[axis]
      if pad_length <= 0:
          return x
  
      pad_width = [(0, 0)] * x.ndim
      right_pad = (0, pad_length)
      pad_width[axis] = right_pad if is_right_pad else right_pad[::-1]
      return np.pad(x, mode="constant", pad_width=pad_width)
  
file_path: gluonts/src/gluonts/mx/batchify.py
imports: import functools
  from typing import List, Optional, Type
  import mxnet
  import numpy
  from gluonts.dataset.common import DataBatch
label_desc: Use image node_id 1 for calling a global function with example usage: pad_to_size(x, size, axis, is_right_pad) and returns: np, x