code: def _moving_block_bootstrap(
      ts: pd.Series,
      block_length: int,
      replacement: bool = False,
      random_state: Union[int, np.random.RandomState] = None,
  ) -> pd.Series:
      """Create a synthetic time series using the moving block bootstrap method MBB.
  
      Parameters
      ----------
      ts : pd.Series
          a stationary time series
      block_length : int
          The length of the bootstrapping block
      replacement: bool, optional
          Whether the sample is with or without replacement, by default True.
      random_state : int, np.random.RandomState or None, by default None
          Controls the randomness of the estimator
  
      Returns
      -------
      pd.Series
          synthetic time series
      """
      ts_length = len(ts)
      ts_index = ts.index
      ts_values = ts.values
      rng = check_random_state(random_state)
  
      if ts_length <= block_length:
          raise ValueError(
              "X length in moving block bootstrapping should be greater"
              " than block_length"
          )
  
      if block_length == 1 and not replacement:
          mbb_values = copy(ts_values)
          rng.shuffle(mbb_values)
      elif block_length == 1:
          mbb_values = rng.choice(
              ts_values, size=ts_length, replace=replacement
          )
      else:
          total_num_blocks = int(ts_length / block_length) + 2
          block_origns = rng.choice(
              ts_length - block_length + 1,
              size=total_num_blocks,
              replace=replacement,
          )
          mbb_values = [
              val
              for i in block_origns
              for val in ts_values[i : i + block_length]
          ]
          # remove the first few observations and ensure new series has the
          # same length as the original
          remove_first = rng.choice(block_length - 1)
          mbb_values = mbb_values[
              remove_first : remove_first + ts_length
          ]
  
      mbb_series = pd.Series(data=mbb_values, index=ts_index)
  
      return mbb_series
  
imports: from copy import copy
  from typing import Tuple, Union
  import numpy
  import pandas
  from sklearn.utils import check_random_state
  from sktime.transformations.base import BaseTransformer
  from sktime.transformations.series.boxcox import BoxCoxTransformer
label_desc: Use image node_id 1 for calling a global function with example usage: _moving_block_bootstrap(ts, block_length, replacement, random_state) and returns: mbb_series