code: def reinforce_loss_with_MCtree(
      sample_fn,  # pylint: disable=invalid-name
      global_reward_fn,
      local_reward_fn=None,
      num_samples=1,
  ):
      """Computes REINFORCE loss with Monte Carlo tree search.
  
      Args:
          sample_fn: A callable that takes :attr:`num_samples`, 'given_actions'
              and returns `(samples, probabilities, sequence_lengths)`, where:
  
              `samples` is a Tensor of shape `[num_samples, max_sequence_length]`
              containing the generated samples;
  
              `probabilities` is a Tensor of shape
              `[num_samples, max_sequence_length]` containing the probabilities of
              generating each position of the samples. Probabilities beyond the
              respective sequence lengths are ignored.
  
              `sequence_lengths` is a Tensor of shape `[num_samples]` containing
              the length of each samples.
          global_reward_fn: A callable that takes `(samples, sequence_lengths)`
              and returns a Tensor of shape `[num_samples]` containing the reward
              of each of the samples.
          local_reward_fn (optional): A callable that takes
              `(samples, sequence_lengths)` and returns a Tensor of shape
              `[num_samples, max_sequence_length]` containing the local reward
              at each time step of samples.
          num_samples (int scalar Tensor): the number of sequences to sample.
  
      Returns:
          A scalar Tensor of the REINFORCE loss.
      """
      raise NotImplementedError
  
imports: import tensorflow
  from texar.tf.losses.mle_losses import _mask_sequences
label_desc: Use image node_id 2 for calling a global function with example usage: reinforce_loss_with_MCtree(sample_fn, global_reward_fn, local_reward_fn, num_samples) without return types