def get_var(list_of_tensors, prefix_name=None, with_name=None):
  """Gets specific variable.

  Args:
    list_of_tensors: A list of candidate tensors
    prefix_name:  Variable name starts with prefix_name
    with_name: with_name in the variable name

  Returns:
    Obtained tensor list
  """
  if prefix_name is None:
    return list_of_tensors
  else:
    specific_tensor = []
    specific_tensor_name = []
    if prefix_name is not None:
      for var in list_of_tensors:
        if var.name.startswith(prefix_name):
          if with_name is None or with_name in var.name:
            specific_tensor.append(var)
            specific_tensor_name.append(var.name)
    return specific_tensor