code: def _resize_data(
      input_data: Var,
      dims: Tuple[int],
      sizes: Tuple[int],
      before_op: Operation,
  ) -> Var:
      """
      For each dim in `dims`, resize the input data size to corresponding size in `sizes`.
      If the `size` is smaller than the data's size at `dim`, trim the data to `size`.
      If the `size` is larger, pad zeros to make the data reaches `size`.
      """
      for dim, size in zip(dims, sizes):
          if size < input_data.shape[dim]:
              indices = mb.range_1d(
                  start=0, end=size, step=1, before_op=before_op
              )
              input_data = mb.gather(
                  x=input_data,
                  indices=indices,
                  axis=dim,
                  before_op=before_op,
              )
          elif size > input_data.shape[dim]:
              zero_shape = list(input_data.shape)
              zero_shape[dim] = size - input_data.shape[dim]
              zero_data = mb.fill(
                  shape=zero_shape, value=0.0, before_op=before_op
              )
              input_data = mb.concat(
                  values=[input_data, zero_data],
                  axis=dim,
                  before_op=before_op,
              )
  
      return input_data
  
imports: import functools
  from typing import Callable, Dict, Optional, Tuple
  import numpy
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.operation import Operation
  from coremltools.converters.mil.mil.ops.defs.complex_dialect_ops import fft_canonicalize_length_dim, fft_canonicalize_shapes_dims
  from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass
  from coremltools.converters.mil.mil.passes.helper import block_context_manager
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
  from coremltools.converters.mil.mil.var import ComplexVar, Var
label_desc: Use image node_id 1 for calling a global function with example usage: _resize_data(input_data, dims, sizes, before_op) and returns: input_data